diff options
author | Hyunjun Ko <zzoon.ko@samsung.com> | 2012-08-21 18:01:56 +0900 |
---|---|---|
committer | Hyunjun Ko <zzoon.ko@samsung.com> | 2012-08-21 18:01:56 +0900 |
commit | 198987b2e1fcc91d4da409017f870801e0d06664 (patch) | |
tree | 744862158b748898c8305fa0ace85c70e8fa93a7 | |
parent | aaaa695e5509775ef100360642a02970af7f76a9 (diff) | |
download | media-content-198987b2e1fcc91d4da409017f870801e0d06664.tar.gz media-content-198987b2e1fcc91d4da409017f870801e0d06664.tar.bz2 media-content-198987b2e1fcc91d4da409017f870801e0d06664.zip |
Tizen 2.0 beta
56 files changed, 21234 insertions, 10253 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 9f98683..b9373bf 100644..100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -9,7 +9,7 @@ SET(PREFIX ${CMAKE_INSTALL_PREFIX}) SET(INC_DIR include) INCLUDE_DIRECTORIES(${INC_DIR}) -SET(dependents "dlog libmedia-service drm-service aul capi-base-common") +SET(dependents "dlog libmedia-service libmedia-utils capi-base-common") SET(pc_dependents "dlog capi-base-common") INCLUDE(FindPkgConfig) diff --git a/TC/_export_env.sh b/TC/_export_env.sh new file mode 100755 index 0000000..85deee1 --- /dev/null +++ b/TC/_export_env.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_HOST_PATH # tetware root path +#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator # tetware target 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 +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/_export_target_env.sh b/TC/_export_target_env.sh new file mode 100755 index 0000000..79666a1 --- /dev/null +++ b/TC/_export_target_env.sh @@ -0,0 +1,8 @@ +#!/bin/sh +. ./config +export TET_INSTALL_PATH=$TET_INSTALL_TARGET_PATH # path to path +#export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-simulator +export TET_TARGET_PATH=$TET_INSTALL_PATH/tetware-target +export PATH=$TET_TARGET_PATH/bin:$PATH +export LD_LIBRARY_PATH=$TET_TARGET_PATH/lib/tet3:$LD_LIBRARY_PATH +export TET_ROOT=$TET_TARGET_PATH diff --git a/TC/build.sh b/TC/build.sh new file mode 100755 index 0000000..72aad6c --- /dev/null +++ b/TC/build.sh @@ -0,0 +1,16 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/build-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -c -p ./ +tcc -b -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/clean.sh b/TC/clean.sh new file mode 100755 index 0000000..29743e0 --- /dev/null +++ b/TC/clean.sh @@ -0,0 +1,11 @@ +#!/bin/sh + +. ./_export_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +RESULT_DIR=results + +tcc -c -p ./ # executing tcc, with clean option (-c) +rm -r $RESULT_DIR +rm -r tet_tmp_dir +rm testcase/tet_captured diff --git a/TC/config b/TC/config new file mode 100644 index 0000000..64713a4 --- /dev/null +++ b/TC/config @@ -0,0 +1,2 @@ +TET_INSTALL_HOST_PATH=/home/dydot1kim/project/dts/SLP_DTS_v1.3/TETware +TET_INSTALL_TARGET_PATH=/mnt/nfs/project/dts/SLP_DTS_v1.3/TETware diff --git a/TC/execute.sh b/TC/execute.sh new file mode 100755 index 0000000..0fe02e2 --- /dev/null +++ b/TC/execute.sh @@ -0,0 +1,15 @@ +#!/bin/sh + +. ./_export_target_env.sh # setting environment variables + +export TET_SUITE_ROOT=`pwd` +FILE_NAME_EXTENSION=`date +%s` + +RESULT_DIR=results +HTML_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.html +JOURNAL_RESULT=$RESULT_DIR/exec-tar-result-$FILE_NAME_EXTENSION.journal + +mkdir -p $RESULT_DIR + +tcc -e -j $JOURNAL_RESULT -p ./ +grw -c 7 -f chtml -o $HTML_RESULT $JOURNAL_RESULT diff --git a/TC/testcase/Makefile b/TC/testcase/Makefile new file mode 100644 index 0000000..fa03d3a --- /dev/null +++ b/TC/testcase/Makefile @@ -0,0 +1,23 @@ +CC ?= gcc + +C_FILES = $(shell ls *.c) + +PKGS = capi-content-media-content +LDFLAGS = `pkg-config --libs $(PKGS)` +LDFLAGS += $(TET_ROOT)/lib/tet3/tcm_s.o +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -ltcm_s +LDFLAGS += -L$(TET_ROOT)/lib/tet3 -lapi_s + +CFLAGS = -I. `pkg-config --cflags $(PKGS)` +CFLAGS += -I$(TET_ROOT)/inc/tet3 +CFLAGS += -Wall + +TCS := $(shell ls -1 *.c | cut -d. -f1) + +all: $(TCS) + +%: %.c + $(CC) -o $@ $< $(CFLAGS) $(LDFLAGS) + +clean: + rm -f $(TCS) diff --git a/TC/testcase/tet_captured b/TC/testcase/tet_captured new file mode 100644 index 0000000..409eaf3 --- /dev/null +++ b/TC/testcase/tet_captured @@ -0,0 +1 @@ +make: `utc_media_tag' is up to date. diff --git a/TC/testcase/tslist b/TC/testcase/tslist new file mode 100755 index 0000000..ecea559 --- /dev/null +++ b/TC/testcase/tslist @@ -0,0 +1,10 @@ +/testcase/utc_media_content +/testcase/utc_media_folder +/testcase/utc_media_filter +/testcase/utc_media_image +/testcase/utc_media_video +/testcase/utc_media_info +/testcase/utc_media_audio +/testcase/utc_media_tag +/testcase/utc_media_group +/testcase/utc_media_playlist diff --git a/TC/testcase/utc_media_audio.c b/TC/testcase/utc_media_audio.c new file mode 100755 index 0000000..efe5e06 --- /dev/null +++ b/TC/testcase/utc_media_audio.c @@ -0,0 +1,756 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <stdlib.h> +#include <media_content.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_audio_meta_destroy_n(void); +static void utc_audio_meta_destroy_p(void); +static void utc_audio_meta_clone_n(void); +static void utc_audio_meta_clone_p(void); +static void utc_audio_meta_get_media_id_n(void); +static void utc_audio_meta_get_media_id_p(void); +static void utc_audio_meta_get_title_n(void); +static void utc_audio_meta_get_title_p(void); +static void utc_audio_meta_get_album_n(void); +static void utc_audio_meta_get_album_p(void); +static void utc_audio_meta_get_artist_n(void); +static void utc_audio_meta_get_artist_p(void); +static void utc_audio_meta_get_genre_n(void); +static void utc_audio_meta_get_genre_p(void); +static void utc_audio_meta_get_composer_n(void); +static void utc_audio_meta_get_composer_p(void); +static void utc_audio_meta_get_year_n(void); +static void utc_audio_meta_get_year_p(void); +static void utc_audio_meta_get_recorded_date_n(void); +static void utc_audio_meta_get_recorded_date_p(void); +static void utc_audio_meta_get_copyright_n(void); +static void utc_audio_meta_get_copyright_p(void); +static void utc_audio_meta_get_track_num_n(void); +static void utc_audio_meta_get_track_num_p(void); +static void utc_audio_meta_get_bit_rate_n(void); +static void utc_audio_meta_get_bit_rate_p(void); +static void utc_audio_meta_get_sample_rate_n(void); +static void utc_audio_meta_get_sample_rate_p(void); +static void utc_audio_meta_get_channel_n(void); +static void utc_audio_meta_get_channel_p(void); +static void utc_audio_meta_get_duration_n(void); +static void utc_audio_meta_get_duration_p(void); +static void utc_audio_meta_get_played_count_n(void); +static void utc_audio_meta_get_played_count_p(void); +static void utc_audio_meta_get_played_time_n(void); +static void utc_audio_meta_get_played_time_p(void); +static void utc_audio_meta_get_played_position_n(void); +static void utc_audio_meta_get_played_position_p(void); +static void utc_audio_meta_update_to_db_n(void); +static void utc_audio_meta_update_to_db_p(void); +static void utc_audio_meta_set_played_count_n(void); +static void utc_audio_meta_set_played_count_p(void); +static void utc_audio_meta_set_played_time_n(void); +static void utc_audio_meta_set_played_time_p(void); +static void utc_audio_meta_set_played_position_n(void); +static void utc_audio_meta_set_played_position_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_audio_meta_destroy_n, 5 }, + { utc_audio_meta_destroy_p, 5 }, + { utc_audio_meta_clone_n, 4 }, + { utc_audio_meta_clone_p, 4 }, + { utc_audio_meta_get_media_id_n, 1 }, + { utc_audio_meta_get_media_id_p, 1 }, + { utc_audio_meta_get_title_n, 1 }, + { utc_audio_meta_get_title_p, 1 }, + { utc_audio_meta_get_album_n, 1 }, + { utc_audio_meta_get_album_p, 1 }, + { utc_audio_meta_get_artist_n, 1 }, + { utc_audio_meta_get_artist_p, 1 }, + { utc_audio_meta_get_genre_n, 1 }, + { utc_audio_meta_get_genre_p, 1 }, + { utc_audio_meta_get_composer_n, 1 }, + { utc_audio_meta_get_composer_p, 1 }, + { utc_audio_meta_get_year_n, 1 }, + { utc_audio_meta_get_year_p, 1 }, + { utc_audio_meta_get_recorded_date_n, 1 }, + { utc_audio_meta_get_recorded_date_p, 1 }, + { utc_audio_meta_get_copyright_n, 1 }, + { utc_audio_meta_get_copyright_p, 1 }, + { utc_audio_meta_get_track_num_n, 1 }, + { utc_audio_meta_get_track_num_p, 1 }, + { utc_audio_meta_get_bit_rate_n, 1 }, + { utc_audio_meta_get_bit_rate_p, 1 }, + { utc_audio_meta_get_sample_rate_n, 1 }, + { utc_audio_meta_get_sample_rate_p, 1 }, + { utc_audio_meta_get_channel_n, 1 }, + { utc_audio_meta_get_channel_p, 1 }, + { utc_audio_meta_get_duration_n, 1 }, + { utc_audio_meta_get_duration_p, 1 }, + { utc_audio_meta_get_played_count_n, 1 }, + { utc_audio_meta_get_played_count_p, 1 }, + { utc_audio_meta_get_played_time_n, 1 }, + { utc_audio_meta_get_played_time_p, 1 }, + { utc_audio_meta_get_played_position_n, 1 }, + { utc_audio_meta_get_played_position_p, 1 }, + { utc_audio_meta_set_played_count_n, 2 }, + { utc_audio_meta_set_played_count_p, 2 }, + { utc_audio_meta_set_played_time_n, 2 }, + { utc_audio_meta_set_played_time_p, 2 }, + { utc_audio_meta_set_played_position_n, 2 }, + { utc_audio_meta_set_played_position_p, 2 }, + { utc_audio_meta_update_to_db_n, 3 }, + { utc_audio_meta_update_to_db_p, 3 }, + { NULL, 0 }, +}; + +static audio_meta_h g_audio; +static audio_meta_h g_audio_dst; +static char *g_media_id = NULL; + +bool media_item_cb(media_info_h media, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_get_media_id(media, &g_media_id); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) + { + tet_printf("\n get media_id failed"); + return false; + } + + ret = media_info_get_audio(media, &g_audio); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_audio == NULL)) + { + tet_printf("\n get audio_meta failed"); + return false; + } + + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + filter_h filter; + g_audio = NULL; + g_audio_dst = NULL; + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + { + tet_printf("\n database connection is success"); + } + + char *condition = "MEDIA_TYPE=3"; //Music + + media_filter_create(&filter); + media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT); + if(filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n get media_info failed"); + return; + } + + media_filter_destroy(filter); + + tet_printf("\n TC start END"); +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_media_id != NULL) + free(g_media_id); + + if(g_audio != NULL) + audio_meta_destroy(g_audio); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); +} + +/** + * @brief Negative test case of content_imageinfo_destroy() + */ +static void utc_audio_meta_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = audio_meta_destroy(NULL); + + dts_check_eq("utc_audio_meta_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of content_imageinfo_destroy() + */ +static void utc_audio_meta_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = audio_meta_destroy(g_audio_dst); + + dts_check_eq("utc_audio_meta_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy audio_meta object"); +} + +/** + * @brief Negative test case of imageinfo_clone() + */ +static void utc_audio_meta_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = audio_meta_clone(&g_audio_dst, NULL); + dts_check_eq("utc_audio_meta_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_clone() + */ +static void utc_audio_meta_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = audio_meta_clone(&g_audio_dst, g_audio); + + dts_check_eq("utc_audio_meta_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone audio_meta object"); +} + +/** + * @brief Negative test case of audio_meta_get_media_id() + */ +static void utc_audio_meta_get_media_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = audio_meta_get_media_id(NULL, &media_id); + + dts_check_eq("utc_audio_meta_get_media_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of audio_meta_get_media_id() + */ +static void utc_audio_meta_get_media_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = audio_meta_get_media_id(g_audio, &media_id); + + dts_check_eq("utc_audio_meta_get_media_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album"); +} + +/** + * @brief Negative test case of imageinfo_get_latitude() + */ +static void utc_audio_meta_get_title_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *title = NULL; + + ret = audio_meta_get_title(NULL, &title); + + dts_check_eq("utc_audio_meta_get_album_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_get_latitude() + */ +static void utc_audio_meta_get_title_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *title = NULL; + + ret = audio_meta_get_title(g_audio, &title); + + if(title) + free(title); + + dts_check_eq("utc_audio_meta_get_album_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album"); +} + +/** + * @brief Negative test case of imageinfo_get_latitude() + */ +static void utc_audio_meta_get_album_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album = NULL; + + ret = audio_meta_get_album(NULL, &album); + + dts_check_eq("utc_audio_meta_get_album_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_get_latitude() + */ +static void utc_audio_meta_get_album_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album = NULL; + + ret = audio_meta_get_album(g_audio, &album); + + if(album) + free(album); + + dts_check_eq("utc_audio_meta_get_album_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album"); +} + +/** + * @brief Negative test case of imageinfo_get_description() + */ +static void utc_audio_meta_get_artist_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *artist = NULL; + + ret = audio_meta_get_artist(NULL, &artist); + + dts_check_eq("utc_audio_meta_get_artist_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_get_description() + */ +static void utc_audio_meta_get_artist_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *artist = NULL; + + ret = audio_meta_get_artist(g_audio, &artist); + + if(artist) + free(artist); + + dts_check_eq("utc_audio_meta_get_artist_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get artist"); +} + +/** + * @brief Negative test case of audio_meta_get_genre() + */ +static void utc_audio_meta_get_genre_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *genre = NULL; + + ret = audio_meta_get_genre(NULL, &genre); + dts_check_eq("utc_audio_meta_get_genre_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of audio_meta_get_genre() + */ +static void utc_audio_meta_get_genre_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *genre = NULL; + + ret = audio_meta_get_genre(g_audio, &genre); + + if(genre) + free(genre); + + dts_check_eq("utc_audio_meta_get_genre_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get genre"); +} + +/** + * @brief Negative test case of audio_meta_get_composer() + */ +static void utc_audio_meta_get_composer_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *composer = NULL; + + ret = audio_meta_get_composer(NULL, &composer); + dts_check_eq("utc_audio_meta_get_composer_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + + +/** + * @brief Positive test case of audio_meta_get_composer() + */ +static void utc_audio_meta_get_composer_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *composer = NULL; + + ret = audio_meta_get_composer(g_audio, &composer); + + if(composer) + free(composer); + + dts_check_eq("utc_audio_meta_get_composer_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the composer"); +} + +/** + * @brief Negative test case of sim_get_imageinfo_get_height() + */ +static void utc_audio_meta_get_year_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *year = NULL; + + ret = audio_meta_get_year(NULL, &year); + + dts_check_eq("utc_audio_meta_get_year_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of sim_get_imageinfo_get_height() + */ +static void utc_audio_meta_get_year_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *year = NULL; + + ret = audio_meta_get_year(g_audio, &year); + + if(year) + free(year); + + dts_check_eq("utc_audio_meta_get_year_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get year"); +} + +/** + * @brief Negative test case of audio_meta_get_recorded_date() + */ +static void utc_audio_meta_get_recorded_date_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *recorded_date = NULL; + + ret = audio_meta_get_recorded_date(NULL, &recorded_date); + + dts_check_eq("utc_audio_meta_get_recorded_date_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Failed to get recorded_date"); +} + +/** + * @brief Positive test case of audio_meta_get_recorded_date() + */ +static void utc_audio_meta_get_recorded_date_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *recorded_date = NULL; + + ret = audio_meta_get_year(g_audio, &recorded_date); + + if(recorded_date) + free(recorded_date); + + dts_check_eq("utc_audio_meta_get_recorded_date_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get recorded_date"); +} + +/** + * @brief Negative test case of audio_meta_get_copyright() + */ +static void utc_audio_meta_get_copyright_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *copyright = NULL; + + ret = audio_meta_get_copyright(NULL, ©right); + + dts_check_eq("utc_audio_meta_get_copyright_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of audio_meta_get_copyright() + */ +static void utc_audio_meta_get_copyright_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *copyright = NULL; + + ret = audio_meta_get_copyright(g_audio, ©right); + + if(copyright) + free(copyright); + + dts_check_eq("utc_audio_meta_get_copyright_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get copyright"); +} + +static void utc_audio_meta_get_track_num_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *tracknum = NULL; + + ret = audio_meta_get_track_num(NULL, &tracknum); + + dts_check_eq("utc_audio_meta_get_track_num_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_track_num_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *tracknum = NULL; + + ret = audio_meta_get_track_num(g_audio, &tracknum); + + if(tracknum) + free(tracknum); + + dts_check_eq("utc_audio_meta_get_track_num_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get track num"); +} + +static void utc_audio_meta_get_bit_rate_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int bit_rate = 0; + + ret = audio_meta_get_bit_rate(NULL, &bit_rate); + + dts_check_eq("utc_audio_meta_get_bit_rate_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_bit_rate_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int bit_rate = 0; + + ret = audio_meta_get_bit_rate(g_audio, &bit_rate); + + dts_check_eq("utc_audio_meta_get_bit_rate_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the bit_rate"); +} + +static void utc_audio_meta_get_sample_rate_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int sample_rate = 0; + + ret = audio_meta_get_sample_rate(NULL, &sample_rate); + + dts_check_eq("utc_audio_meta_get_sample_rate_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_sample_rate_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int sample_rate = 0; + + ret = audio_meta_get_sample_rate(g_audio, &sample_rate); + + dts_check_eq("utc_audio_meta_get_sample_rate_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the sample_rate"); +} + +static void utc_audio_meta_get_channel_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int channel = 0; + + ret = audio_meta_get_channel(NULL, &channel); + + dts_check_eq("utc_audio_meta_get_sample_rate_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_channel_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int channel = 0; + + ret = audio_meta_get_channel(g_audio, &channel); + + dts_check_eq("utc_audio_meta_get_sample_rate_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the channel"); +} + +static void utc_audio_meta_get_duration_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int duration = 0; + + ret = audio_meta_get_duration(NULL, &duration); + + dts_check_eq("utc_audio_meta_get_duration_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_duration_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int duration = 0; + + ret = audio_meta_get_duration(g_audio, &duration); + + dts_check_eq("utc_audio_meta_get_duration_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get duration"); +} + +static void utc_audio_meta_get_played_count_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int count = 0; + + ret = audio_meta_get_played_count(NULL, &count); + + dts_check_eq("utc_audio_meta_get_played_count_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_played_count_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int count = 0; + + ret = audio_meta_get_played_count(g_audio, &count); + + dts_check_eq("utc_audio_meta_get_played_count_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played count"); +} + +static void utc_audio_meta_get_played_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = audio_meta_get_played_time(NULL, &played_time); + + dts_check_eq("utc_audio_meta_get_played_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_played_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = audio_meta_get_played_time(g_audio, &played_time); + + dts_check_eq("utc_audio_meta_get_played_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played time"); +} + +static void utc_audio_meta_get_played_position_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int position = 0; + + ret = audio_meta_get_played_position(NULL, &position); + + dts_check_eq("utc_audio_meta_get_played_position_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_get_played_position_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int position = 0; + + ret = audio_meta_get_played_position(g_audio, &position); + + dts_check_eq("utc_audio_meta_get_played_position_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played position"); +} + +static void utc_audio_meta_set_played_count_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_count = 3; + + ret = audio_meta_set_played_count(NULL, played_count); + + dts_check_eq("utc_audio_meta_set_played_count_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_set_played_count_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_count = 3; + + ret = audio_meta_set_played_count(g_audio, played_count); + + dts_check_eq("utc_audio_meta_set_played_count_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set played count"); +} + +static void utc_audio_meta_set_played_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = audio_meta_set_played_time(NULL, played_time); + + dts_check_eq("utc_audio_meta_set_played_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_set_played_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = audio_meta_set_played_time(g_audio, played_time); + + dts_check_eq("utc_audio_meta_set_played_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set played time"); +} + +static void utc_audio_meta_set_played_position_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_position = 0; + + ret = audio_meta_set_played_position(NULL, played_position); + + dts_check_eq("audio_meta_set_played_position", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_set_played_position_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_position = 0; + + ret = audio_meta_set_played_position(g_audio, played_position); + + dts_check_eq("utc_audio_meta_set_played_position_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set playedposition"); +} + +static void utc_audio_meta_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = audio_meta_update_to_db(NULL); + + dts_check_eq("utc_audio_meta_update_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_audio_meta_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + tet_printf("audio : 0x%x\n", g_audio); + ret = audio_meta_update_to_db(g_audio); + + dts_check_eq("utc_audio_meta_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update metadata"); +} diff --git a/TC/testcase/utc_media_content.c b/TC/testcase/utc_media_content.c new file mode 100755 index 0000000..8eb44fe --- /dev/null +++ b/TC/testcase/utc_media_content.c @@ -0,0 +1,78 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_content_connect_p(void); +static void utc_media_content_disconnect_p(void); + + + +struct tet_testlist tet_testlist[] = { + { utc_media_content_connect_p, 1 }, + { utc_media_content_disconnect_p, 1 }, + { NULL, 0 }, +}; + + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); +} + + +/** + * @brief Positive test case of utc_media_content_connect_p() + */ +static void utc_media_content_connect_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_content_connect(); + + dts_check_eq("utc_media_content_connect_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to connect database"); +} + + +/** + * @brief Positive test case of utc_media_content_disconnect_p() + */ +static void utc_media_content_disconnect_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_content_disconnect(); + + dts_check_eq("utc_content_imageinfo_destroy", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to disconnect database"); +} diff --git a/TC/testcase/utc_media_filter.c b/TC/testcase/utc_media_filter.c new file mode 100755 index 0000000..72ce5a1 --- /dev/null +++ b/TC/testcase/utc_media_filter.c @@ -0,0 +1,303 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_filter_create_n(void); +static void utc_media_filter_create_p(void); +static void utc_media_filter_destroy_n(void); +static void utc_media_filter_destroy_p(void); +static void utc_media_filter_set_offset_n(void); +static void utc_media_filter_set_offset_p(void); +static void utc_media_filter_set_condition_n(void); +static void utc_media_filter_set_condition_p(void); +static void utc_media_filter_set_order_n(void); +static void utc_media_filter_set_order_p(void); +//static void utc_media_filter_set_collate_n(void); +//static void utc_media_filter_set_collate_p(void); +static void utc_media_filter_get_offset_n(void); +static void utc_media_filter_get_offset_p(void); +static void utc_media_filter_get_condition_n(void); +static void utc_media_filter_get_condition_p(void); +static void utc_media_filter_get_order_n(void); +static void utc_media_filter_get_order_p(void); +//static void utc_media_filter_get_collate_n(void); +//static void utc_media_filter_get_collate_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_media_filter_create_n, 1 }, + { utc_media_filter_create_p, 1 }, + { utc_media_filter_destroy_n, 4 }, + { utc_media_filter_destroy_p, 4 }, + { utc_media_filter_set_offset_n, 2 }, + { utc_media_filter_set_offset_p, 2}, + { utc_media_filter_set_condition_n, 2 }, + { utc_media_filter_set_condition_p, 2 }, + { utc_media_filter_set_order_n, 2 }, + { utc_media_filter_set_order_p, 2 }, +// { utc_media_filter_set_collate_n, 2 }, +// { utc_media_filter_set_collate_p, 2 }, + { utc_media_filter_get_offset_n, 3 }, + { utc_media_filter_get_offset_p, 3}, + { utc_media_filter_get_condition_n, 3 }, + { utc_media_filter_get_condition_p, 3 }, + { utc_media_filter_get_order_n, 3 }, + { utc_media_filter_get_order_p, 3 }, +// { utc_media_filter_get_collate_n, 3 }, +// { utc_media_filter_get_collate_p, 3 }, + { NULL, 0 }, +}; + + +//media_folder_h g_folder = NULL; +static filter_h g_filter = NULL; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); +} + + + +/** + * @brief Negative test case of media_filter_create() + */ +static void utc_media_filter_create_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_create(NULL); + + dts_check_eq("utc_media_filter_create_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_create() + */ +static void utc_media_filter_create_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_create(&g_filter); + + dts_check_eq("utc_media_filter_create_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to create the filter"); +} + +/** + * @brief Negative test case of media_filter_destroy() + */ +static void utc_media_filter_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_destroy(NULL); + + dts_check_eq("utc_media_filter_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_destroy() + */ +static void utc_media_filter_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_destroy(g_filter); + + dts_check_eq("utc_media_filter_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy filter"); +} + +/** + * @brief Negative test case of media_filter_get_offset() + */ +static void utc_media_filter_set_offset_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_offset(NULL, 0, 3); + + dts_check_eq("utc_media_filter_set_offset_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_get_offset() + */ +static void utc_media_filter_set_offset_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_offset(g_filter, 0, 3); + + dts_check_eq("utc_media_filter_set_offset_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set the offset"); +} + +/** + * @brief Negative test case of utc_media_filter_get_display_name() + */ +static void utc_media_filter_set_condition_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_condition(NULL, "MEDIA_TYPE=3", MEDIA_CONTENT_COLLATE_DEFAULT); + + dts_check_eq("utc_media_filter_set_condition_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of utc_media_filter_get_display_name() + */ +static void utc_media_filter_set_condition_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_condition(g_filter, "MEDIA_TYPE=3", MEDIA_CONTENT_COLLATE_DEFAULT); + + dts_check_eq("utc_media_filter_set_condition_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set display name"); +} + +/** + * @brief Negative test case of media_filter_set_order() + */ +static void utc_media_filter_set_order_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_order(NULL, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT); + + dts_check_eq("utc_media_filter_set_order_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_set_order() + */ +static void utc_media_filter_set_order_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT); + + dts_check_eq("utc_media_filter_set_order_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set the order"); +} + +/** + * @brief Negative test case of media_filter_get_offset() + */ +static void utc_media_filter_get_offset_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int offset = 0; + int count = 0; + + ret = media_filter_get_offset(NULL, &offset, &count); + + dts_check_eq("utc_media_filter_get_offset_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_get_offset() + */ +static void utc_media_filter_get_offset_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int offset = 0; + int count = 0; + + ret = media_filter_get_offset(g_filter, &offset, &count); + + dts_check_eq("utc_media_filter_get_offset_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the offset"); +} + +/** + * @brief Negative test case of utc_media_filter_get_display_name() + */ +static void utc_media_filter_get_condition_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *condition = NULL; + media_content_collation_e collate_type = -1; + + ret = media_filter_get_condition(NULL, &condition, &collate_type); + + dts_check_eq("utc_media_filter_get_display_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of utc_media_filter_get_display_name() + */ +static void utc_media_filter_get_condition_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *condition = NULL; + media_content_collation_e collate_type = -1; + + ret = media_filter_get_condition(g_filter, &condition, &collate_type); + + if(condition != NULL) + free(condition); + + dts_check_eq("utc_media_filter_get_display_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get display name"); +} + +/** + * @brief Negative test case of media_filter_get_order() + */ +static void utc_media_filter_get_order_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_order_e order; + char *order_keyword = NULL; + media_content_collation_e collate_type = -1; + + ret = media_filter_get_order(NULL, &order, &order_keyword, &collate_type); + + dts_check_eq("utc_media_filter_get_order_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_filter_get_order() + */ +static void utc_media_filter_get_order_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_order_e order = 0; + char *order_keyword = NULL; + media_content_collation_e collate_type = -1; + + ret = media_filter_get_order(g_filter, &order, &order_keyword, &collate_type); + + if(order_keyword != NULL) + free(order_keyword); + + dts_check_eq("utc_media_filter_get_order_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the order"); +} diff --git a/TC/testcase/utc_media_folder.c b/TC/testcase/utc_media_folder.c new file mode 100755 index 0000000..262b46e --- /dev/null +++ b/TC/testcase/utc_media_folder.c @@ -0,0 +1,552 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_folder_foreach_folder_from_db_n(void); +static void utc_media_folder_foreach_folder_from_db_p(void); +static void utc_media_folder_get_media_count_from_db_n(void); +static void utc_media_folder_get_media_count_from_db_p(void); +static void utc_media_folder_foreach_media_from_db_n(void); +static void utc_media_folder_foreach_media_from_db_p(void); +static void utc_media_folder_destroy_n(void); +static void utc_media_folder_destroy_p(void); +static void utc_media_folder_clone_n(void); +static void utc_media_folder_clone_p(void); +static void utc_media_folder_get_path_n(void); +static void utc_media_folder_get_path_p(void); +static void utc_media_folder_get_name_n(void); +static void utc_media_folder_get_name_p(void); +static void utc_media_folder_get_date_modified_n(void); +static void utc_media_folder_get_date_modified_p(void); +static void utc_media_folder_get_storage_type_n(void); +static void utc_media_folder_get_storage_type_p(void); +static void utc_media_folder_update_to_db_n(void); +static void utc_media_folder_update_to_db_p(void); +static void utc_media_folder_set_name_n(void); +static void utc_media_folder_set_name_p(void); +static void utc_media_folder_get_folder_id_n(void); +static void utc_media_folder_get_folder_id_p(void); +static void utc_media_folder_get_folder_from_db_n(void); +static void utc_media_folder_get_folder_from_db_p(void); +static void utc_media_folder_get_folder_count_from_db_n(void); +static void utc_media_folder_get_folder_count_from_db_p(void); + +struct tet_testlist tet_testlist[] = { + { utc_media_folder_foreach_folder_from_db_n, 1 }, + { utc_media_folder_foreach_folder_from_db_p, 1 }, + { utc_media_folder_get_media_count_from_db_n, 2 }, + { utc_media_folder_get_media_count_from_db_p, 2 }, + { utc_media_folder_foreach_media_from_db_n, 2 }, + { utc_media_folder_foreach_media_from_db_p, 2 }, + { utc_media_folder_destroy_n, 3 }, + { utc_media_folder_destroy_p, 3 }, + { utc_media_folder_clone_n, 2 }, + { utc_media_folder_clone_p, 2 }, + { utc_media_folder_get_path_n, 2 }, + { utc_media_folder_get_path_p, 2 }, + { utc_media_folder_get_path_p, 2 }, + { utc_media_folder_get_name_n, 2 }, + { utc_media_folder_get_name_p, 2 }, + { utc_media_folder_get_date_modified_n, 2 }, + { utc_media_folder_get_date_modified_p, 2 }, + { utc_media_folder_get_storage_type_n, 2 }, + { utc_media_folder_get_storage_type_p, 2 }, + { utc_media_folder_set_name_n, 2 }, + { utc_media_folder_set_name_p, 2 }, + { utc_media_folder_update_to_db_n, 2 }, + { utc_media_folder_update_to_db_p, 2 }, + { utc_media_folder_get_folder_id_n, 2 }, + { utc_media_folder_get_folder_id_p, 2 }, + { utc_media_folder_get_folder_from_db_n, 2 }, + { utc_media_folder_get_folder_from_db_p, 2 }, + { utc_media_folder_get_folder_count_from_db_n, 2 }, + { utc_media_folder_get_folder_count_from_db_p, 2 }, + { NULL, 0 }, +}; + + +media_folder_h g_folder = NULL; +media_folder_h g_test_folder = NULL; +const char *g_test_folder_path = "/opt/media/Images/test"; +const char *g_default_folder_path = "/opt/media/Images"; +const char *g_origin_item_path = "/opt/media/Images/Default.jpg"; +const char *g_test_item_path = "/opt/media/Images/test/test.jpg"; +char *g_folder_path = NULL; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_content_connect(); + + char mkdir_str[256] = {0, }; + char test_copy[256] = {0, }; + snprintf(mkdir_str, sizeof(mkdir_str), "/bin/mkdir %s", g_test_folder_path); + snprintf(test_copy, sizeof(test_copy), "/bin/cp %s %s", g_origin_item_path, g_test_item_path); + + system(mkdir_str); + system(test_copy); + + sleep(1); +} + +static void cleanup(void) +{ + /* end of TC */ + int ret = MEDIA_CONTENT_ERROR_NONE; + ret = media_content_disconnect(); + + unlink(g_test_item_path); + + char rmdir_str[256] = {0, }; + snprintf(rmdir_str, sizeof(rmdir_str), "/bin/rmdir %s", g_test_folder_path); + system(rmdir_str); + tet_printf("\n TC end"); + + media_folder_destroy(g_folder); + media_folder_destroy(g_test_folder); + + if (g_folder_path) free(g_folder_path); + g_folder_path = NULL; +} + +bool capi_folder_list_cb(media_folder_h folder, void *user_data) +{ + if(folder != NULL) + { + media_folder_get_path(folder, &g_folder_path); + + tet_printf("folder path : %s\n", g_folder_path); + + if(strcmp(g_folder_path, g_test_folder_path) == 0) { + tet_printf("TEST folder\n"); + media_folder_clone(&g_test_folder, folder); + } else if(strcmp(g_folder_path, g_default_folder_path) == 0) { + tet_printf("DEFAULT folder\n"); + media_folder_clone(&g_folder, folder); + } + } + + if (g_folder_path) free(g_folder_path); + g_folder_path = NULL; + + return true; +} + +/** + * @brief Negative test case of media_folder_foreach_folder_from_db() + */ +static void utc_media_folder_foreach_folder_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_foreach_folder_from_db(NULL, NULL, NULL); + + dts_check_eq("utc_media_folder_foreach_folder_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_foreach_folder_from_db() + */ +static void utc_media_folder_foreach_folder_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter; + + media_filter_create(&filter); + + ret = media_folder_foreach_folder_from_db(filter, capi_folder_list_cb, NULL); + dts_check_eq("utc_media_folder_foreach_folder_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to iterate the folder"); +} + +/** + * @brief Negative test case of media_folder_get_media_count_from_db() + */ +static void utc_media_folder_get_media_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int cnt; + + ret = media_folder_get_media_count_from_db(NULL, NULL, &cnt); + + dts_check_eq("utc_media_folder_get_media_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_media_count_from_db() + */ +static void utc_media_folder_get_media_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int cnt; + + filter_h filter; + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + char *folder_id = NULL; + media_folder_get_folder_id(g_folder, &folder_id); + + ret = media_folder_get_media_count_from_db(folder_id, filter, &cnt); + + dts_check_eq("utc_media_folder_get_media_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the count of media"); +} + +bool sub_media_cb(media_info_h media, void *user_data) +{ + return true; +} + +/** + * @brief Negative test case of media_folder_foreach_media_from_db() + */ +static void utc_media_folder_foreach_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + filter_h filter; + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_folder_foreach_media_from_db(NULL, filter, sub_media_cb, NULL); + + media_filter_destroy(filter); + + dts_check_eq("utc_media_folder_foreach_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_foreach_media_from_db() + */ +static void utc_media_folder_foreach_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + filter_h filter; + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + char *folder_id = NULL; + media_folder_get_folder_id(g_folder, &folder_id); + + ret = media_folder_foreach_media_from_db(folder_id, filter, sub_media_cb, NULL); + + media_filter_destroy(filter); + + dts_check_eq("utc_media_folder_foreach_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to iterate the media"); +} + +/** + * @brief Negative test case of media_folder_destroy() + */ +static void utc_media_folder_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_destroy(NULL); + + dts_check_eq("utc_media_folder_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_destroy() + */ +static void utc_media_folder_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_destroy(g_folder); + + dts_check_eq("utc_media_folder_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy the folder"); +} + +/** + * @brief Negative test case of media_folder_clone() + */ +static void utc_media_folder_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_h dst_folder = NULL; + + ret = media_folder_clone(&dst_folder, NULL); + + dts_check_eq("utc_media_folder_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_clone() + */ +static void utc_media_folder_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_h dst_folder = NULL; + + ret = media_folder_clone(&dst_folder, g_folder); + + if(dst_folder != NULL) + media_folder_destroy(dst_folder); + + dts_check_eq("utc_media_folder_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone the folder"); +} + +/** + * @brief Negative test case of media_folder_get_path() + */ +static void utc_media_folder_get_path_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *path = NULL; + ret = media_folder_get_path(NULL, &path); + + dts_check_eq("utc_media_folder_get_path_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_path() + */ +static void utc_media_folder_get_path_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *path = NULL; + ret = media_folder_get_path(g_folder, &path); + + if(path != NULL) + free(path); + + dts_check_eq("utc_media_folder_get_path_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the path"); +} + +/** + * @brief Negative test case of media_folder_get_name() + */ +static void utc_media_folder_get_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + ret = media_folder_get_name(NULL, &name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_folder_get_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_name() + */ +static void utc_media_folder_get_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + ret = media_folder_get_name(g_folder, &name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_folder_get_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the name"); +} + +/** + * @brief Negative test case of media_folder_get_storage_type() + */ +static void utc_media_folder_get_date_modified_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t date_modifed = 0; + + ret = media_folder_get_modified_time(NULL, &date_modifed); + + dts_check_eq("utc_media_folder_get_storage_type_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_storage_type() + */ +static void utc_media_folder_get_date_modified_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t date_modifed = 0; + ret = media_folder_get_modified_time(g_folder, &date_modifed); + + dts_check_eq("utc_media_folder_get_storage_type_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_get_storage_type() + */ +static void utc_media_folder_get_storage_type_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_storage_e type; + + ret = media_folder_get_storage_type(NULL, &type); + + dts_check_eq("utc_media_folder_get_storage_type_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_storage_type() + */ +static void utc_media_folder_get_storage_type_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_storage_e type; + + ret = media_folder_get_storage_type(g_folder, &type); + + dts_check_eq("utc_media_folder_get_storage_type_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_set_name() + */ +static void utc_media_folder_set_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_set_name(NULL, NULL); + + dts_check_eq("utc_media_folder_set_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_set_name() + */ +static void utc_media_folder_set_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_set_name(g_test_folder, "new test"); + + dts_check_eq("utc_media_folder_set_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_update_to_db() + */ +static void utc_media_folder_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_update_to_db(NULL); + + dts_check_eq("utc_media_folder_update_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_update_to_db() + */ +static void utc_media_folder_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_update_to_db(g_test_folder); + + dts_check_eq("utc_media_folder_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_get_folder_id() + */ +static void utc_media_folder_get_folder_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_get_folder_id(NULL, NULL); + + dts_check_eq("utc_media_folder_get_folder_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_folder_id() + */ +static void utc_media_folder_get_folder_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *folder_id = NULL; + ret = media_folder_get_folder_id(g_folder, &folder_id); + + dts_check_eq("utc_media_folder_get_folder_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_get_folder_from_db() + */ +static void utc_media_folder_get_folder_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_get_folder_from_db(NULL, NULL); + + dts_check_eq("utc_media_folder_get_folder_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_folder_from_db() + */ +static void utc_media_folder_get_folder_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *folder_id = NULL; + media_folder_get_folder_id(g_folder, &folder_id); + media_folder_h folder_info; + + ret = media_folder_get_folder_from_db(folder_id, &folder_info); + + dts_check_eq("utc_media_folder_get_folder_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} + +/** + * @brief Negative test case of media_folder_get_folder_count_from_db() + */ +static void utc_media_folder_get_folder_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_folder_get_folder_count_from_db(NULL, NULL); + + dts_check_eq("utc_media_folder_get_folder_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of media_folder_get_folder_count_from_db() + */ +static void utc_media_folder_get_folder_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int cnt = 0; + + filter_h filter; + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_folder_get_folder_count_from_db(filter, &cnt); + + dts_check_eq("utc_media_folder_get_folder_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the storage type"); +} diff --git a/TC/testcase/utc_media_group.c b/TC/testcase/utc_media_group.c new file mode 100755 index 0000000..eb692bc --- /dev/null +++ b/TC/testcase/utc_media_group.c @@ -0,0 +1,401 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <stdlib.h> +#include <media_content.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_album_get_album_count_from_db_n(void); +static void utc_media_album_get_album_count_from_db_p(void); +static void utc_media_album_foreach_album_from_db_n(void); +static void utc_media_album_foreach_album_from_db_p(void); +static void utc_media_album_get_media_count_from_db_n(void); +static void utc_media_album_get_media_count_from_db_p(void); +static void utc_media_album_foreach_media_from_db_n(void); +static void utc_media_album_foreach_media_from_db_p(void); +static void utc_media_album_get_album_from_db_n(void); +static void utc_media_album_get_album_from_db_p(void); +static void utc_media_album_get_album_id_n(void); +static void utc_media_album_get_album_id_p(void); +static void utc_media_album_get_name_n(void); +static void utc_media_album_get_name_p(void); +static void utc_media_album_get_artist_n(void); +static void utc_media_album_get_artist_p(void); +static void utc_media_album_get_album_art_n(void); +static void utc_media_album_get_album_art_p(void); +static void utc_media_album_clone_n(void); +static void utc_media_album_clone_p(void); +static void utc_media_album_destroy_n(void); +static void utc_media_album_destroy_p(void); + +struct tet_testlist tet_testlist[] = { + { utc_media_album_get_album_count_from_db_n, 1 }, + { utc_media_album_get_album_count_from_db_p, 1 }, + { utc_media_album_foreach_album_from_db_n, 1 }, + { utc_media_album_foreach_album_from_db_p, 1 }, + { utc_media_album_get_media_count_from_db_n, 1 }, + { utc_media_album_get_media_count_from_db_p, 1 }, + { utc_media_album_foreach_media_from_db_n, 1 }, + { utc_media_album_foreach_media_from_db_p, 1 }, + { utc_media_album_get_album_from_db_n, 2}, + { utc_media_album_get_album_from_db_p, 2}, + { utc_media_album_get_album_id_n, 3}, + { utc_media_album_get_album_id_p, 3}, + { utc_media_album_get_name_n, 3}, + { utc_media_album_get_name_p, 3}, + { utc_media_album_get_artist_n, 3}, + { utc_media_album_get_artist_p, 3}, + { utc_media_album_get_album_art_n, 3}, + { utc_media_album_get_album_art_p, 3}, + { utc_media_album_clone_n, 3}, + { utc_media_album_clone_p, 3}, + { utc_media_album_destroy_n, 4}, + { utc_media_album_destroy_p, 4}, + { NULL, 0 }, +}; + +static media_album_h g_album; +static media_album_h g_album_dst; +static filter_h g_filter; +static int g_album_id = 0; +static char *g_album_name = NULL; +static char *g_artist_name = NULL; +static char *g_genre_name = NULL; +static char *g_composer_name = NULL; +static char *g_year_name = NULL; + +bool media_item_cb(media_info_h media, void *user_data) +{ + return true; +} + +bool album_cb(media_album_h album, void *user_data) +{ + if(album != NULL) + { + media_album_get_album_id(album, &g_album_id); + media_album_get_name(album, &g_album_name); + } + + return true; +} + +bool group_cb(const char *name, void *user_data) +{ + if(name != NULL) + { + if(!strcmp((char*)user_data, "artist")) + g_artist_name = strdup(name); + else if(!strcmp((char*)user_data, "genre")) + g_genre_name = strdup(name); + else if(!strcmp((char*)user_data, "composer")) + g_composer_name = strdup(name); + else if(!strcmp((char*)user_data, "year")) + g_year_name = strdup(name); + + tet_printf("\n get group name success"); + } + + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + { + tet_printf("\n database connection is success"); + } + + char *condition = "MEDIA_TYPE=3"; //Music + + media_filter_create(&g_filter); + media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_TITLE", MEDIA_CONTENT_COLLATE_DEFAULT); + if(g_filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + tet_printf("\n TC start END"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_album_name != NULL) + free(g_album_name); + + if(g_artist_name != NULL) + free(g_artist_name); + + if(g_genre_name != NULL) + free(g_genre_name); + + if(g_composer_name != NULL) + free(g_composer_name); + + if(g_year_name != NULL) + free(g_year_name); + + if(g_filter != NULL) + media_filter_destroy(g_filter); + + if(g_album != NULL) + media_album_destroy(g_album); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); + +} + + +static void utc_media_album_get_album_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_album_count_from_db(g_filter, NULL); + + dts_check_eq("utc_media_album_get_album_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_album_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int album_count = 0; + + ret = media_album_get_album_count_from_db(g_filter, &album_count); + + dts_check_eq("utc_media_album_get_album_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album count"); +} + +static void utc_media_album_foreach_album_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_foreach_album_from_db(g_filter, NULL, NULL); + + dts_check_eq("utc_media_album_foreach_album_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_foreach_album_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_foreach_album_from_db(g_filter, album_cb, NULL); + + dts_check_eq("utc_media_album_foreach_album_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album media"); +} + +static void utc_media_album_get_media_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + + ret = media_album_get_media_count_from_db(0, g_filter, &media_count); + + dts_check_eq("utc_media_album_get_media_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_media_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + + ret = media_album_get_media_count_from_db(g_album_id, g_filter, &media_count); + + dts_check_eq("utc_media_album_get_media_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album media count"); +} + +static void utc_media_album_foreach_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_foreach_media_from_db(0, g_filter, media_item_cb, NULL); + + dts_check_eq("utc_media_album_foreach_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_foreach_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_foreach_media_from_db(g_album_id, g_filter, media_item_cb, NULL); + + dts_check_eq("utc_media_album_foreach_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album media count"); +} + +static void utc_media_album_get_album_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_album_from_db(-1, &g_album); + + dts_check_eq("utc_media_album_get_album_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_album_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_album_from_db(g_album_id, &g_album); + + dts_check_eq("utc_media_album_get_album_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album by album_id"); +} + +static void utc_media_album_get_album_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_album_id(g_album, NULL); + + dts_check_eq("utc_media_album_get_album_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_album_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int album_id = 0; + + ret = media_album_get_album_id(g_album, &album_id); + + dts_check_eq("utc_media_album_get_album_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album id"); +} + +static void utc_media_album_get_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_name(NULL, NULL); + + dts_check_eq("utc_media_album_get_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album_name = NULL; + + ret = media_album_get_name(g_album, &album_name); + + if(album_name) + free(album_name); + + dts_check_eq("utc_media_album_get_album_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album name"); +} + +static void utc_media_album_get_artist_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_artist(NULL, NULL); + + dts_check_eq("utc_media_album_get_artist_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_artist_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *artist_name = NULL; + + ret = media_album_get_artist(g_album, &artist_name); + + if(artist_name) + free(artist_name); + + dts_check_eq("utc_media_album_get_artist_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get artist name"); +} + +static void utc_media_album_get_album_art_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_get_album_art(NULL, NULL); + + dts_check_eq("utc_media_album_get_album_art_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_get_album_art_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album_art = NULL; + + ret = media_album_get_album_art(g_album, &album_art); + + if(album_art) + free(album_art); + + dts_check_eq("utc_media_album_get_album_art_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get album_art path"); +} + +static void utc_media_album_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_clone(NULL, NULL); + + dts_check_eq("utc_media_album_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_clone(&g_album_dst, g_album); + + dts_check_eq("utc_media_album_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone album"); +} + +static void utc_media_album_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_destroy(NULL); + + dts_check_eq("utc_media_album_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_album_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_album_destroy(g_album_dst); + + dts_check_eq("utc_media_album_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy album"); +} diff --git a/TC/testcase/utc_media_image.c b/TC/testcase/utc_media_image.c new file mode 100755 index 0000000..0808f57 --- /dev/null +++ b/TC/testcase/utc_media_image.c @@ -0,0 +1,362 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_image_meta_destroy_n(void); +static void utc_image_meta_destroy_p(void); +static void utc_image_meta_clone_n(void); +static void utc_image_meta_clone_p(void); +static void utc_image_meta_get_media_id_n(void); +static void utc_image_meta_get_media_id_p(void); +static void utc_image_meta_get_width_n(void); +static void utc_image_meta_get_width_p(void); +static void utc_image_meta_get_height_n(void); +static void utc_image_meta_get_height_p(void); +static void utc_image_meta_get_orientation_n(void); +static void utc_image_meta_get_orientation_p(void); +static void utc_image_meta_get_date_taken_n(void); +static void utc_image_meta_get_date_taken_p(void); +static void utc_image_meta_set_orientation_n(void); +static void utc_image_meta_set_orientation_p(void); +static void utc_image_meta_update_to_db_n(void); +static void utc_image_meta_update_to_db_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_image_meta_destroy_n, 5 }, + { utc_image_meta_destroy_p, 5 }, + { utc_image_meta_clone_n, 4 }, + { utc_image_meta_clone_p, 4 }, + { utc_image_meta_get_media_id_n, 1 }, + { utc_image_meta_get_media_id_p, 1 }, + { utc_image_meta_get_width_n, 1 }, + { utc_image_meta_get_width_p, 1 }, + { utc_image_meta_get_height_n, 1 }, + { utc_image_meta_get_height_p, 1 }, + { utc_image_meta_get_orientation_n, 1 }, + { utc_image_meta_get_orientation_p, 1 }, + { utc_image_meta_get_date_taken_n, 1 }, + { utc_image_meta_get_date_taken_p, 1 }, + { utc_image_meta_set_orientation_n, 2 }, + { utc_image_meta_set_orientation_p, 2 }, + { utc_image_meta_update_to_db_n, 3 }, + { utc_image_meta_update_to_db_p, 3 }, + { NULL, 0 }, +}; + +static image_meta_h g_image; +static image_meta_h g_image_dst; +static char *g_media_id = NULL; + +bool media_item_cb(media_info_h media, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_get_media_id(media, &g_media_id); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) + { + tet_printf("\n get media_id failed"); + return false; + } + + ret = media_info_get_image(media, &g_image); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_image == NULL)) + { + tet_printf("\n get image_meta failed"); + return false; + } + + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + filter_h filter; + g_image = NULL; + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + tet_printf("\n database connection is success"); + + char *condition = "MEDIA_TYPE=0"; //Image + + media_filter_create(&filter); + media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_DISPLAY_NAME, MEDIA_CONTENT_COLLATE_DEFAULT); + if(filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n get media_info failed"); + return; + } + + media_filter_destroy(filter); + + tet_printf("\n TC start END"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_media_id != NULL) + free(g_media_id); + + if(g_image != NULL) + image_meta_destroy(g_image); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); +} + + +/** + * @brief Negative test case of content_image_meta_destroy() + */ +static void utc_image_meta_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_destroy(NULL); + + dts_check_eq("utc_image_meta_destroy", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + + +/** + * @brief Positive test case of content_image_meta_destroy() + */ +static void utc_image_meta_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_destroy(g_image_dst); + + dts_check_eq("utc_image_meta_destroy", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy imageinfo object"); +} + +/** + * @brief Negative test case of image_meta_clone() + */ +static void utc_image_meta_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_clone(&g_image_dst, NULL); + + dts_check_eq("utc_image_meta_clone", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of image_meta_clone() + */ +static void utc_image_meta_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_clone(&g_image_dst, g_image); + + dts_check_eq("utc_image_meta_clone", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone imageinfo object"); +} + +/** + * @brief Negative test case of image_meta_get_media_id() + */ +static void utc_image_meta_get_media_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = image_meta_get_media_id(NULL, &media_id); + + dts_check_eq("utc_image_meta_get_media_id", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of image_meta_get_media_id() + */ +static void utc_image_meta_get_media_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = image_meta_get_media_id(g_image, &media_id); + + dts_check_eq("utc_image_meta_get_media_id", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the media_id"); +} + +/** + * @brief Negative test case of image_meta_get_width() + */ +static void utc_image_meta_get_width_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int width = 0; + + ret = image_meta_get_width(NULL, &width); + + dts_check_eq("utc_image_meta_get_width", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of image_meta_get_width() + */ +static void utc_image_meta_get_width_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int width = 0; + + ret = image_meta_get_width(g_image, &width); + + dts_check_eq("utc_image_meta_get_width", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the width"); +} + +/** + * @brief Negative test case of sim_get_image_meta_get_height() + */ +static void utc_image_meta_get_height_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int height = 0; + + ret = image_meta_get_height(NULL, &height); + + dts_check_eq("utc_image_meta_get_height", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of sim_get_image_meta_get_height() + */ +static void utc_image_meta_get_height_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int height = 0; + + ret = image_meta_get_height(g_image, &height); + + dts_check_eq("utc_image_meta_get_height", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get height"); +} + +/** + * @brief Negative test case of sim_get_image_meta_get_orientation() + */ +static void utc_image_meta_get_orientation_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_orientation_e orientation = 0; + + ret = image_meta_get_orientation(NULL, &orientation); + + dts_check_eq("utc_image_meta_get_orientation", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of sim_get_image_meta_get_orientation() + */ +static void utc_image_meta_get_orientation_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_orientation_e orientation = 0; + + ret = image_meta_get_orientation(g_image, &orientation); + + dts_check_eq("utc_image_meta_get_orientation", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get orientation"); +} + +static void utc_image_meta_get_date_taken_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *date_taken = NULL; + + ret = image_meta_get_date_taken(NULL, &date_taken); + + dts_check_eq("utc_image_meta_get_date_taken", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_image_meta_get_date_taken_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *date_taken = NULL; + + ret = image_meta_get_date_taken(g_image, &date_taken); + + dts_check_eq("utc_image_meta_get_date_taken", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get date_taken"); +} + +static void utc_image_meta_set_orientation_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_set_orientation(NULL, MEDIA_CONTENT_ORIENTATION_NORMAL); + + dts_check_eq("utc_image_meta_set_orientation_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_image_meta_set_orientation_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_set_orientation(g_image, MEDIA_CONTENT_ORIENTATION_NORMAL); + + dts_check_eq("utc_image_meta_set_orientation_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get date_taken"); +} + +static void utc_image_meta_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_update_to_db(NULL); + + dts_check_eq("utc_image_meta_update_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_image_meta_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = image_meta_update_to_db(g_image); + + dts_check_eq("utc_image_meta_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get date_taken"); +} diff --git a/TC/testcase/utc_media_info.c b/TC/testcase/utc_media_info.c new file mode 100755 index 0000000..0c8051d --- /dev/null +++ b/TC/testcase/utc_media_info.c @@ -0,0 +1,1573 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_media_info_insert_to_db_n(void); +static void utc_media_info_insert_to_db_p(void); +static void utc_media_info_set_display_name_n(void); +static void utc_media_info_set_display_name_p(void); +static void utc_media_info_set_favorite_n(void); +static void utc_media_info_set_favorite_p(void); +static void utc_media_info_set_rating_n(void); +static void utc_media_info_set_rating_p(void); +static void utc_media_info_set_category_n(void); +static void utc_media_info_set_category_p(void); +static void utc_media_info_set_location_tag_n(void); +static void utc_media_info_set_location_tag_p(void); +static void utc_media_info_set_provider_n(void); +static void utc_media_info_set_provider_p(void); +static void utc_media_info_set_content_name_n(void); +static void utc_media_info_set_content_name_p(void); +static void utc_media_info_set_description_n(void); +static void utc_media_info_set_description_p(void); +static void utc_media_info_set_author_n(void); +static void utc_media_info_set_author_p(void); +static void utc_media_info_set_age_rating_n(void); +static void utc_media_info_set_age_rating_p(void); +static void utc_media_info_set_added_time_n(void); +static void utc_media_info_set_added_time_p(void); +static void utc_media_info_set_keyword_n(void); +static void utc_media_info_set_keyword_p(void); +static void utc_media_info_set_altitude_n(void); +static void utc_media_info_set_altitude_p(void); +static void utc_media_info_set_latitude_n(void); +static void utc_media_info_set_latitude_p(void); +static void utc_media_info_set_longitude_n(void); +static void utc_media_info_set_longitude_p(void); +static void utc_media_info_update_to_db_n(void); +static void utc_media_info_update_to_db_p(void); +static void utc_media_info_move_media_to_db_n(void); +static void utc_media_info_move_media_to_db_p(void); +static void utc_media_info_delete_from_db_n(void); +static void utc_media_info_delete_from_db_p(void); +static void utc_media_info_foreach_media_from_db_n(void); +static void utc_media_info_foreach_media_from_db_p(void); +static void utc_media_info_refresh_metadata_to_db_n(void); +static void utc_media_info_refresh_metadata_to_db_p(void); +static void utc_media_info_destroy_n(void); +static void utc_media_info_destroy_p(void); +static void utc_media_info_clone_n(void); +static void utc_media_info_clone_p(void); +static void utc_media_info_get_media_id_n(void); +static void utc_media_info_get_media_id_p(void); +static void utc_media_info_get_file_path_n(void); +static void utc_media_info_get_file_path_p(void); +static void utc_media_info_get_display_name_n(void); +static void utc_media_info_get_display_name_p(void); +static void utc_media_info_get_media_type_n(void); +static void utc_media_info_get_media_type_p(void); +static void utc_media_info_get_mime_type_n(void); +static void utc_media_info_get_mime_type_p(void); +static void utc_media_info_get_thumbnail_path_n(void); +static void utc_media_info_get_thumbnail_path_p(void); +static void utc_media_info_get_modified_time_n(void); +static void utc_media_info_get_modified_time_p(void); +static void utc_media_info_get_size_n(void); +static void utc_media_info_get_size_p(void); +static void utc_media_info_get_description_n(void); +static void utc_media_info_get_description_p(void); +static void utc_media_info_get_rating_n(void); +static void utc_media_info_get_rating_p(void); +static void utc_media_info_get_location_tag_n(void); +static void utc_media_info_get_location_tag_p(void); +static void utc_media_info_get_provider_n(void); +static void utc_media_info_get_provider_p(void); +static void utc_media_info_get_content_name_n(void); +static void utc_media_info_get_content_name_p(void); +static void utc_media_info_get_category_n(void); +static void utc_media_info_get_category_p(void); +static void utc_media_info_get_age_rating_n(void); +static void utc_media_info_get_age_rating_p(void); +static void utc_media_info_get_keyword_n(void); +static void utc_media_info_get_keyword_p(void); +static void utc_media_info_get_author_n(void); +static void utc_media_info_get_author_p(void); +static void utc_media_info_get_added_time_n(void); +static void utc_media_info_get_added_time_p(void); +static void utc_media_info_get_altitude_n(void); +static void utc_media_info_get_altitude_p(void); +static void utc_media_info_get_latitude_n(void); +static void utc_media_info_get_latitude_p(void); +static void utc_media_info_get_longitude_n(void); +static void utc_media_info_get_longitude_p(void); +static void utc_media_info_get_storage_type_n(void); +static void utc_media_info_get_storage_type_p(void); +static void utc_media_info_is_drm_n(void); +static void utc_media_info_is_drm_p(void); +static void utc_media_info_get_media_from_db_n(void); +static void utc_media_info_get_media_from_db_p(void); +static void utc_media_info_get_image_n(void); +static void utc_media_info_get_image_p(void); +static void utc_media_info_get_video_n(void); +static void utc_media_info_get_video_p(void); +static void utc_media_info_get_audio_n(void); +static void utc_media_info_get_audio_p(void); +static void utc_media_info_foreach_tag_from_db_n(void); +static void utc_media_info_foreach_tag_from_db_p(void); +static void utc_media_info_get_favorite_n(void); +static void utc_media_info_get_favorite_p(void); +static void utc_media_info_foreach_bookmark_from_db_n(void); +static void utc_media_info_foreach_bookmark_from_db_p(void); +static void utc_media_info_get_bookmark_count_from_db_n(void); +static void utc_media_info_get_bookmark_count_from_db_p(void); +static void utc_media_info_get_media_count_from_db_n(void); +static void utc_media_info_get_media_count_from_db_p(void); +static void utc_media_info_get_tag_count_from_db_n(void); +static void utc_media_info_get_tag_count_from_db_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_media_info_insert_to_db_n, 1 }, + { utc_media_info_insert_to_db_p, 1 }, + { utc_media_info_set_display_name_n, 1 }, + { utc_media_info_set_display_name_p, 1 }, + { utc_media_info_set_favorite_n, 1 }, + { utc_media_info_set_favorite_p, 1 }, + { utc_media_info_set_rating_n, 1 }, + { utc_media_info_set_rating_p, 1 }, + { utc_media_info_set_category_n, 1 }, + { utc_media_info_set_category_p, 1 }, + { utc_media_info_set_location_tag_n, 1 }, + { utc_media_info_set_location_tag_p, 1 }, + { utc_media_info_set_provider_n, 1 }, + { utc_media_info_set_provider_p, 1 }, + { utc_media_info_set_content_name_n, 1 }, + { utc_media_info_set_content_name_p, 1 }, + { utc_media_info_set_description_n, 1 }, + { utc_media_info_set_description_p, 1 }, + { utc_media_info_set_author_n, 1 }, + { utc_media_info_set_author_p, 1 }, + { utc_media_info_set_age_rating_n, 1 }, + { utc_media_info_set_age_rating_p, 1 }, + { utc_media_info_set_added_time_n, 1 }, + { utc_media_info_set_added_time_p, 1 }, + { utc_media_info_set_keyword_n, 1 }, + { utc_media_info_set_keyword_p, 1 }, + { utc_media_info_set_altitude_n, 1 }, + { utc_media_info_set_altitude_p, 1 }, + { utc_media_info_set_longitude_n, 1 }, + { utc_media_info_set_longitude_p, 1 }, + { utc_media_info_set_latitude_n, 1 }, + { utc_media_info_set_latitude_p, 1 }, + { utc_media_info_update_to_db_n, 1 }, + { utc_media_info_update_to_db_p, 1 }, + { utc_media_info_move_media_to_db_n, 1 }, + { utc_media_info_move_media_to_db_p, 1 }, + { utc_media_info_delete_from_db_n, 1 }, + { utc_media_info_delete_from_db_p, 1 }, + { utc_media_info_foreach_media_from_db_n, 1 }, + { utc_media_info_foreach_media_from_db_p, 1 }, + { utc_media_info_refresh_metadata_to_db_n, 1 }, + { utc_media_info_refresh_metadata_to_db_p, 1 }, + { utc_media_info_clone_n, 2 }, + { utc_media_info_clone_p, 2 }, + { utc_media_info_destroy_n, 5 }, + { utc_media_info_destroy_p, 5 }, + { utc_media_info_get_media_id_n, 2 }, + { utc_media_info_get_media_id_p, 2 }, + { utc_media_info_get_file_path_n, 2 }, + { utc_media_info_get_file_path_p, 2 }, + { utc_media_info_get_display_name_n, 2 }, + { utc_media_info_get_display_name_p, 2 }, + { utc_media_info_get_thumbnail_path_n, 2 }, + { utc_media_info_get_thumbnail_path_p, 2 }, + { utc_media_info_get_modified_time_n, 2 }, + { utc_media_info_get_modified_time_p, 2 }, + { utc_media_info_get_media_type_n, 2 }, + { utc_media_info_get_media_type_p, 2 }, + { utc_media_info_get_size_n, 2 }, + { utc_media_info_get_size_p, 2 }, + { utc_media_info_get_description_n, 2 }, + { utc_media_info_get_description_p, 2 }, + { utc_media_info_get_rating_n, 2 }, + { utc_media_info_get_rating_p, 2 }, + { utc_media_info_get_location_tag_n, 2 }, + { utc_media_info_get_location_tag_p, 2 }, + { utc_media_info_get_provider_n, 2 }, + { utc_media_info_get_provider_p, 2 }, + { utc_media_info_get_content_name_n, 2 }, + { utc_media_info_get_content_name_p, 2 }, + { utc_media_info_get_category_n, 2 }, + { utc_media_info_get_category_p, 2 }, + { utc_media_info_get_age_rating_n, 2 }, + { utc_media_info_get_age_rating_p, 2 }, + { utc_media_info_get_keyword_n, 2 }, + { utc_media_info_get_keyword_p, 2 }, + { utc_media_info_get_author_n, 2 }, + { utc_media_info_get_author_p, 2 }, + { utc_media_info_get_altitude_n, 2 }, + { utc_media_info_get_altitude_p, 2 }, + { utc_media_info_get_longitude_n, 2 }, + { utc_media_info_get_longitude_p, 2 }, + { utc_media_info_get_latitude_n, 2 }, + { utc_media_info_get_latitude_p, 2 }, + { utc_media_info_get_storage_type_n, 2 }, + { utc_media_info_get_storage_type_p, 2 }, + { utc_media_info_get_added_time_n, 2 }, + { utc_media_info_get_added_time_p, 2 }, + { utc_media_info_get_mime_type_n, 2 }, + { utc_media_info_get_mime_type_p, 2 }, + { utc_media_info_is_drm_n, 2 }, + { utc_media_info_is_drm_p, 2 }, + { utc_media_info_get_media_from_db_n, 2 }, + { utc_media_info_get_media_from_db_p, 2 }, + { utc_media_info_get_image_n, 2 }, + { utc_media_info_get_image_p, 2 }, + { utc_media_info_get_video_n, 2 }, + { utc_media_info_get_video_p, 2 }, + { utc_media_info_get_audio_n, 2 }, + { utc_media_info_get_audio_p, 2 }, + { utc_media_info_get_favorite_n, 2 }, + { utc_media_info_get_favorite_p, 2 }, + { utc_media_info_foreach_tag_from_db_n, 3 }, + { utc_media_info_foreach_tag_from_db_p, 3 }, + { utc_media_info_foreach_bookmark_from_db_n, 3 }, + { utc_media_info_foreach_bookmark_from_db_p, 3 }, + { utc_media_info_get_bookmark_count_from_db_n, 3 }, + { utc_media_info_get_bookmark_count_from_db_p, 3 }, + { utc_media_info_get_media_count_from_db_n, 3 }, + { utc_media_info_get_media_count_from_db_p, 3 }, + { utc_media_info_get_tag_count_from_db_n, 3 }, + { utc_media_info_get_tag_count_from_db_p, 3 }, + { NULL, 0 }, +}; + +static media_info_h g_item; +static media_info_h g_vitem; +static media_info_h g_aitem; +static media_info_h g_inserted_media_handle; + + +char *g_item_media_id = NULL; +char *g_inserted_media_id = NULL; +const char *g_insert_path = "/opt/media/Downloads/test.jpg"; +const char *g_origin_path = "/opt/media/Images/Default.jpg"; +const char *g_move_dst_path = "/opt/media/Downloads/test1.jpg"; + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + g_item = NULL; + g_vitem = NULL; + g_aitem = NULL; + g_inserted_media_handle = NULL; + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + tet_printf("\n database connection is success"); + + char test_copy[256] = {0, }; + snprintf(test_copy, sizeof(test_copy), "/bin/cp %s %s", g_origin_path, g_insert_path); + system(test_copy); +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); + + if(g_item_media_id != NULL) + free(g_item_media_id); + + if(g_inserted_media_id != NULL) + free(g_inserted_media_id); + + unlink(g_insert_path); +} + + +static void utc_media_info_insert_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_insert_to_db(NULL, NULL); + + dts_check_eq("utc_media_info_insert_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_insert_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_insert_to_db(g_insert_path, &g_inserted_media_handle); + media_info_get_media_id(g_inserted_media_handle, &g_inserted_media_id); + + dts_check_eq("utc_media_info_insert_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to insert a item"); +} + +static void utc_media_info_set_display_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_display_name(NULL, "new name"); + + dts_check_eq("utc_media_info_set_display_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_display_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_display_name(g_inserted_media_handle, "new name"); + + dts_check_eq("utc_media_info_set_display_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set display name"); +} + +static void utc_media_info_set_favorite_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_favorite(NULL, true); + + dts_check_eq("utc_media_info_set_favorite_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_favorite_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_favorite(g_inserted_media_handle, true); + + dts_check_eq("utc_media_info_set_favorite_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set favorite "); +} + +static void utc_media_info_set_altitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_altitude(NULL, 1000.0); + + dts_check_eq("utc_media_info_set_altitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_altitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_altitude(g_inserted_media_handle, 1000.0); + + dts_check_eq("utc_media_info_set_altitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set favorite "); +} + +static void utc_media_info_set_latitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_latitude(NULL, 1000.0); + + dts_check_eq("utc_media_info_set_latitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_latitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_latitude(g_inserted_media_handle, 1000.0); + + dts_check_eq("utc_media_info_set_latitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set favorite "); +} + +static void utc_media_info_set_longitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_longitude(NULL, 1000.0); + + dts_check_eq("utc_media_info_set_longitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_longitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_longitude(g_inserted_media_handle, 1000.0); + + dts_check_eq("utc_media_info_set_longitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set favorite "); +} + +static void utc_media_info_set_rating_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_rating(NULL, 5); + + dts_check_eq("utc_media_info_set_rating_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_rating_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_rating(g_inserted_media_handle, 5); + + dts_check_eq("utc_media_info_set_rating_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set rating "); +} + +static void utc_media_info_set_category_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_category(NULL, "new cate"); + + dts_check_eq("utc_media_info_set_category_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_category_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_category(g_inserted_media_handle, "new cate"); + + dts_check_eq("utc_media_info_set_category_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set category "); +} + +static void utc_media_info_set_location_tag_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_favorite(NULL, "new location"); + + dts_check_eq("utc_media_info_set_location_tag_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_location_tag_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_location_tag(g_inserted_media_handle, "new location"); + + dts_check_eq("utc_media_info_set_location_tag_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set location tag "); +} + +static void utc_media_info_set_provider_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_provider(NULL, "new provider"); + + dts_check_eq("utc_media_info_set_provider_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_provider_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_provider(g_inserted_media_handle, "new provider"); + + dts_check_eq("utc_media_info_set_provider_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set provider "); +} + +static void utc_media_info_set_content_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_content_name(NULL, "new content"); + + dts_check_eq("utc_media_info_set_content_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_content_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_content_name(g_inserted_media_handle, "new content"); + dts_check_eq("utc_media_info_set_content_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set content name "); +} + +static void utc_media_info_set_description_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_description(NULL, "new description"); + + dts_check_eq("utc_media_info_set_description_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_description_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_description(g_inserted_media_handle, "new description"); + + dts_check_eq("utc_media_info_set_description_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set description "); +} + +static void utc_media_info_set_author_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_author(NULL, "new author"); + + dts_check_eq("utc_media_info_set_author_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_author_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_author(g_inserted_media_handle, "new author"); + + dts_check_eq("utc_media_info_set_description_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set author "); +} + +static void utc_media_info_set_age_rating_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_age_rating(NULL, "new rating"); + + dts_check_eq("utc_media_info_set_age_rating_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_age_rating_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_age_rating(g_inserted_media_handle, "new rating"); + + dts_check_eq("utc_media_info_set_age_rating_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set age rating "); +} + +static void utc_media_info_set_added_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_added_time(NULL, 0); + + dts_check_eq("utc_media_info_set_added_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_added_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + time_t added_time; + time(&added_time); + + ret = media_info_set_added_time(g_inserted_media_handle, added_time); + + dts_check_eq("utc_media_info_set_added_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set added time"); +} + +static void utc_media_info_set_keyword_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_keyword(NULL, "new keyword"); + + dts_check_eq("utc_media_info_set_keyword_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_set_keyword_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_set_keyword(g_inserted_media_handle, "new keyword"); + + dts_check_eq("utc_media_info_set_keyword_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set keyword "); +} + +static void utc_media_info_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_update_to_db(NULL); + + dts_check_eq("utc_media_info_update_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_update_to_db(g_inserted_media_handle); + tet_printf("Media Handle : 0x%x \n", g_inserted_media_handle); + + dts_check_eq("utc_media_info_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update a item"); +} + +static void utc_media_info_move_media_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_move_media_to_db(NULL, g_move_dst_path); + + dts_check_eq("utc_media_info_move_media_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_move_media_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_move_media_to_db(g_inserted_media_handle, g_move_dst_path); + tet_printf("Media Handle : 0x%x \n", g_inserted_media_handle); + + dts_check_eq("utc_media_info_move_media_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update a item"); +} + +static void utc_media_info_delete_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_delete_from_db(NULL); + + dts_check_eq("utc_media_info_delete_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_delete_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + tet_printf("Media ID : %s \n", g_inserted_media_id); + ret = media_info_delete_from_db(g_inserted_media_id); + + dts_check_eq("utc_media_info_delete_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to delete a item"); +} + +bool sub_item_cb(media_info_h media, void *user_data) +{ + media_content_type_e type = 0; + char *name = NULL; + + media_info_get_media_type(media, &type); + media_info_get_display_name(media, &name); + if(g_item == NULL && type == MEDIA_CONTENT_TYPE_IMAGE) + { + media_info_clone(&g_item, media); + media_info_get_media_id(media, &g_item_media_id); + tet_printf("content name: %s \n", name); + } + + if(g_vitem == NULL && type == MEDIA_CONTENT_TYPE_VIDEO) + { + tet_printf("MEDIA_CONTENT_TYPE_VIDEO \n"); + tet_printf("media name: %s \n", name); + media_info_clone(&g_vitem, media); + media_info_get_media_id(media, &g_item_media_id); + } + if(g_aitem == NULL && type == MEDIA_CONTENT_TYPE_MUSIC) + { + tet_printf("MEDIA_CONTENT_TYPE_MUSIC \n"); + tet_printf("media name: %s \n", name); + media_info_clone(&g_aitem, media); + media_info_get_media_id(media, &g_item_media_id); + } + return true; +} + +static void utc_media_info_foreach_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + filter_h filter = NULL; + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0 OR MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_info_foreach_media_from_db(NULL, NULL, NULL); + + if(filter != NULL) + media_filter_destroy(filter); + + + dts_check_eq("utc_media_info_foreach_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_foreach_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + media_filter_create(&filter); + media_filter_set_condition(filter, "MEDIA_TYPE=0 OR MEDIA_TYPE=1 OR MEDIA_TYPE=3", MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_info_foreach_media_from_db(filter, sub_item_cb, NULL); + + if(filter != NULL) + media_filter_destroy(filter); + + dts_check_eq("utc_media_info_foreach_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback fuction"); +} + +static void utc_media_info_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_destroy(NULL); + + dts_check_eq("utc_media_info_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_destroy(g_item); + + dts_check_eq("utc_media_info_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy iteminfo object"); +} + +static void utc_media_info_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_h dst; + + ret = media_info_clone(&dst, NULL); + + dts_check_eq("utc_media_info_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_h dst; + + ret = media_info_clone(&dst, g_item); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_info_destroy(dst); + + dts_check_eq("utc_media_info_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone iteminfo object"); +} + +static void utc_media_info_get_media_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = media_info_get_media_id(NULL, &media_id); + + if(media_id != NULL) + free(media_id); + + dts_check_eq("utc_media_info_get_media_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_media_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + char *media_id = NULL; + ret = media_info_get_media_id(g_item, &media_id); + if(media_id != NULL) + free(media_id); + + dts_check_eq("utc_media_info_get_media_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get media id "); +} + +static void utc_media_info_get_file_path_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *path = NULL; + ret = media_info_get_file_path(NULL, &path); + + if(path != NULL) + free(path); + + dts_check_eq("utc_media_info_get_file_path_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_file_path_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + char *path = NULL; + ret = media_info_get_file_path(g_item, &path); + tet_printf("\n get_file_path : %s\n", path); + if(path != NULL) + free(path); + + dts_check_eq("utc_media_info_get_file_path_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get file path"); +} + +static void utc_media_info_get_display_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + char *name = NULL; + ret = media_info_get_display_name(NULL, &name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_info_get_display_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_display_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + ret = media_info_get_display_name(g_item, &name); + tet_printf("\n media_info_get_display_name : %s\n", name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_info_get_display_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get display_name"); +} + +static void utc_media_info_get_media_type_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_type_e type = 0; + + ret = media_info_get_media_type(NULL, &type); + + dts_check_eq("utc_media_info_get_media_type_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_media_type_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_type_e type = 0; + tet_printf("item : %p\n", g_item); + + ret = media_info_get_media_type(g_item, &type); + + dts_check_eq("utc_media_info_get_media_type_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get content type"); +} + +static void utc_media_info_get_mime_type_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *mime_type; + + ret = media_info_get_author(NULL, &mime_type); + if(mime_type != NULL) + free(mime_type); + + dts_check_eq("utc_media_info_get_mime_type_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_mime_type_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *mime_type; + + ret = media_info_get_mime_type(g_item, &mime_type); + if(mime_type != NULL) + free(mime_type); + + dts_check_eq("utc_media_info_get_mime_type_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get mime_type "); +} + +static void utc_media_info_get_thumbnail_path_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *thumbnail_path = NULL; + ret = media_info_get_thumbnail_path(NULL, &thumbnail_path); + + if(thumbnail_path != NULL) + free(thumbnail_path); + + dts_check_eq("utc_media_info_get_thumbnail_path_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_thumbnail_path_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *thumbnail_path = NULL; + ret = media_info_get_thumbnail_path(g_item, &thumbnail_path); + tet_printf("\n media_info_get_thumbnail_path : %s\n", thumbnail_path); + + if(thumbnail_path != NULL) + free(thumbnail_path); + + dts_check_eq("utc_media_info_get_thumbnail_path_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get thumbail path"); +} + +static void utc_media_info_get_modified_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t date_modi; + ret = media_info_get_modified_time(NULL, &date_modi); + + dts_check_eq("utc_media_info_get_modified_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_modified_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + tet_printf("item : %p\n", g_item); + time_t date_modi; + ret = media_info_get_modified_time(g_item, &date_modi); + + dts_check_eq("utc_media_info_get_modified_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get date modified"); +} + +static void utc_media_info_get_size_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + unsigned long long size; + + ret = media_info_get_size(NULL, &size); + + dts_check_eq("utc_media_info_get_size_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_size_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + unsigned long long size; + + ret = media_info_get_size(g_item, &size); + + dts_check_eq("utc_media_info_get_size_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} + +static void utc_media_info_get_storage_type_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_storage_e storage_type; + + ret = media_info_get_storage_type(NULL, &storage_type); + + dts_check_eq("utc_media_info_get_storage_type_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_storage_type_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_storage_e storage_type; + + ret = media_info_get_storage_type(g_item, &storage_type); + + dts_check_eq("utc_media_info_get_storage_type_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} + +static void utc_media_info_is_drm_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + bool is_drm; + + ret = media_info_is_drm(NULL, &is_drm); + + dts_check_eq("utc_media_info_is_drm_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_is_drm_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + bool is_drm; + + ret = media_info_is_drm(g_item, &is_drm); + + dts_check_eq("utc_media_info_get_is_drm_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} + +static void utc_media_info_get_altitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double altitude; + + ret = media_info_get_altitude(NULL, &altitude); + + dts_check_eq("utc_media_info_get_altitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_altitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double altitude; + + ret = media_info_get_altitude(g_item, &altitude); + + dts_check_eq("utc_media_info_get_altitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} + +static void utc_media_info_get_latitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double latitude; + + ret = media_info_get_altitude(NULL, &latitude); + + dts_check_eq("utc_media_info_get_latitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_latitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double latitude; + + ret = media_info_get_latitude(g_item, &latitude); + + dts_check_eq("utc_media_info_get_latitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} + +static void utc_media_info_get_longitude_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double longitude; + + ret = media_info_get_longitude(NULL, &longitude); + + dts_check_eq("utc_media_info_get_longitude_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_longitude_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + double longitude; + + ret = media_info_get_longitude(g_item, &longitude); + + dts_check_eq("utc_media_info_get_longitude_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get size "); + +} +static void utc_media_info_get_description_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *description; + + ret = media_info_get_description(NULL, &description); + if(description != NULL) + free(description); + + dts_check_eq("utc_media_info_get_description_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_description_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *description; + + ret = media_info_get_description(g_item, &description); + if(description != NULL) + free(description); + + dts_check_eq("utc_media_info_get_description_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get description "); + +} + +static void utc_media_info_get_rating_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int raitng; + + ret = media_info_get_rating(NULL, &raitng); + + dts_check_eq("utc_media_info_get_rating_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_rating_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int raitng; + + ret = media_info_get_rating(g_item, &raitng); + + dts_check_eq("utc_media_info_get_rating_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get raitng "); +} + + +static void utc_media_info_get_location_tag_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *location; + + ret = media_info_get_location_tag(NULL, &location); + if(location != NULL) + free(location); + + dts_check_eq("utc_media_info_get_location_tag_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_location_tag_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *location; + + ret = media_info_get_location_tag(g_item, &location); + if(location != NULL) + free(location); + + dts_check_eq("utc_media_info_get_location_tag_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get location "); +} + +static void utc_media_info_get_provider_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *provider; + + ret = media_info_get_provider(NULL, &provider); + if(provider != NULL) + free(provider); + + dts_check_eq("utc_media_info_get_provider_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_provider_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *provider; + + ret = media_info_get_provider(g_item, &provider); + if(provider != NULL) + free(provider); + + dts_check_eq("utc_media_info_get_provider_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get provider "); +} + +static void utc_media_info_get_content_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *content_name; + + ret = media_info_get_content_name(NULL, &content_name); + if(content_name != NULL) + free(content_name); + + dts_check_eq("utc_media_info_get_content_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_content_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *content_name; + + ret = media_info_get_content_name(g_item, &content_name); + if(content_name != NULL) + free(content_name); + + dts_check_eq("utc_media_info_get_content_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get content_name "); +} + +static void utc_media_info_get_category_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *category; + + ret = media_info_get_category(NULL, &category); + if(category != NULL) + free(category); + + dts_check_eq("utc_media_info_get_category_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_category_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *category; + + ret = media_info_get_category(g_item, &category); + if(category != NULL) + free(category); + + dts_check_eq("utc_media_info_get_category_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get category "); +} + +static void utc_media_info_get_age_rating_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *age_rating; + + ret = media_info_get_age_rating(NULL, &age_rating); + if(age_rating != NULL) + free(age_rating); + + dts_check_eq("utc_media_info_get_age_rating_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_age_rating_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *age_rating; + + ret = media_info_get_age_rating(g_item, &age_rating); + if(age_rating != NULL) + free(age_rating); + + dts_check_eq("utc_media_info_get_age_rating_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get age_rating "); +} + +static void utc_media_info_get_keyword_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *keyword; + + ret = media_info_get_keyword(NULL, &keyword); + if(keyword != NULL) + free(keyword); + + dts_check_eq("utc_media_info_get_keyword_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_keyword_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *keyword; + + ret = media_info_get_keyword(g_item, &keyword); + if(keyword != NULL) + free(keyword); + + dts_check_eq("utc_media_info_get_keyword_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get keyword "); +} + +static void utc_media_info_get_author_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *author; + + ret = media_info_get_author(NULL, &author); + if(author != NULL) + free(author); + + dts_check_eq("utc_media_info_get_author_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_author_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *author; + + ret = media_info_get_author(g_item, &author); + if(author != NULL) + free(author); + + dts_check_eq("utc_media_info_get_author_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get author "); +} + +static void utc_media_info_get_added_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t added_time; + + ret = media_info_get_added_time(NULL, &added_time); + + dts_check_eq("utc_media_info_get_added_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_added_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t added_time; + + ret = media_info_get_added_time(g_item, &added_time); + + dts_check_eq("utc_media_info_get_added_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get added_time "); + +} + +static void utc_media_info_get_favorite_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + bool fav; + ret = media_info_get_favorite(NULL, &fav); + + dts_check_eq("utc_media_info_get_favorite_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_favorite_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + tet_printf("item : %p\n", g_item); + bool fav; + ret = media_info_get_favorite(g_item, &fav); + + dts_check_eq("utc_media_info_get_favorite_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get favorite"); +} + +static void utc_media_info_get_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_h media = NULL; + + ret = media_info_get_media_from_db(NULL, &media); + + if(media != NULL) + media_info_destroy(media); + + dts_check_eq("utc_media_info_get_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_h media = NULL; + + ret = media_info_get_media_from_db(g_item_media_id, &media); + + if(media != NULL) + media_info_destroy(media); + + dts_check_eq("utc_media_info_get_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get mediainfo "); +} + +static void utc_media_info_get_image_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_h image = NULL; + + ret = media_info_get_image(NULL, &image); + + if(image != NULL) + image_meta_destroy(image); + + dts_check_eq("utc_media_info_get_image_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_image_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_h image = NULL; + + ret = media_info_get_image(g_item, &image); + + if(image != NULL) + image_meta_destroy(image); + + dts_check_eq("utc_media_info_get_image_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get imageinfo "); +} + +static void utc_media_info_get_video_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_h video = NULL; + + ret = media_info_get_video(NULL, &video); + + if(video != NULL) + video_meta_destroy(video); + + dts_check_eq("utc_media_info_get_video_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_video_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_h video = NULL; + + ret = media_info_get_video(g_vitem, &video); + + if(video != NULL) + video_meta_destroy(video); + + dts_check_eq("utc_media_info_get_video_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get videoinfo"); +} + +static void utc_media_info_get_audio_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_h audio = NULL; + + ret = media_info_get_audio(NULL, &audio); + + if(audio != NULL) + audio_meta_destroy(audio); + + dts_check_eq("utc_media_info_get_audio_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_audio_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_h audio = NULL; + + ret = media_info_get_audio(g_aitem, &audio); + + if(audio != NULL) + audio_meta_destroy(audio); + + + dts_check_eq("utc_media_info_get_audio_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get audio"); +} + +static void utc_media_info_refresh_metadata_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_refresh_metadata_to_db(NULL); + + dts_check_eq("utc_media_info_refresh_metadata_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_refresh_metadata_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + ret = media_info_refresh_metadata_to_db(g_item_media_id); + + dts_check_eq("utc_media_info_refresh_metadata_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to refresh metadata"); +} + +bool sub_tag_cb(media_tag_h tag, void *user_data) +{ + char *name; + if(tag != NULL) + { + media_tag_get_name(tag, &name); + tet_printf("tag name : %s \n", name); + } + + return false; +} + +bool sub_bookmark_cb(media_bookmark_h bookmark, void *user_data) +{ + int bm_id; + + if(bookmark != NULL) + { + media_bookmark_get_bookmark_id(bookmark, &bm_id); + tet_printf("bookmark id : %d \n", bm_id); + } + + return false; +} + +static void utc_media_info_foreach_tag_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + ret = media_info_foreach_tag_from_db(NULL, filter, NULL, NULL); + + dts_check_eq("utc_media_info_foreach_tag_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_foreach_tag_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + media_filter_create(&filter); + + ret = media_info_foreach_tag_from_db(g_item_media_id, filter, sub_tag_cb, NULL); + + dts_check_eq("utc_media_info_foreach_tag_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback function"); +} + +static void utc_media_info_foreach_bookmark_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + ret = media_info_foreach_tag_from_db(NULL, filter, NULL, NULL); + + dts_check_eq("utc_media_info_foreach_bookmark_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_foreach_bookmark_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + media_filter_create(&filter); + + ret = media_info_foreach_bookmark_from_db(g_item_media_id, filter, sub_bookmark_cb, NULL); + + dts_check_eq("utc_media_info_foreach_bookmark_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback function"); +} + +static void utc_media_info_get_bookmark_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + int count; + + ret = media_info_get_bookmark_count_from_db(NULL, filter, &count); + + dts_check_eq("utc_media_info_get_bookmark_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_bookmark_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + int count; + + media_filter_create(&filter); + + ret = media_info_get_bookmark_count_from_db(g_item_media_id, filter, &count); + + dts_check_eq("utc_media_info_get_bookmark_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback function"); +} + +static void utc_media_info_get_media_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + + ret = media_info_get_media_count_from_db(filter, NULL); + + dts_check_eq("utc_media_info_get_media_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_media_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + int count; + + media_filter_create(&filter); + + ret = media_info_get_media_count_from_db(filter, &count); + + dts_check_eq("utc_media_info_get_media_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback function"); +} + +static void utc_media_info_get_tag_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + int count; + + ret = media_info_get_tag_count_from_db(NULL, filter, &count); + + dts_check_eq("utc_media_info_get_tag_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_info_get_tag_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter = NULL; + int count; + + media_filter_create(&filter); + + ret = media_info_get_tag_count_from_db(g_item_media_id, filter, &count); + + dts_check_eq("utc_media_info_get_tag_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to call callback function"); +} + diff --git a/TC/testcase/utc_media_playlist.c b/TC/testcase/utc_media_playlist.c new file mode 100755 index 0000000..a0f9e50 --- /dev/null +++ b/TC/testcase/utc_media_playlist.c @@ -0,0 +1,519 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <stdlib.h> +#include <media_content.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + + +static void utc_media_playlist_insert_to_db_n(void); +static void utc_media_playlist_insert_to_db_p(void); +static void utc_media_playlist_delete_from_db_n(void); +static void utc_media_playlist_delete_from_db_p(void); +static void utc_media_playlist_get_playlist_count_from_db_n(void); +static void utc_media_playlist_get_playlist_count_from_db_p(void); +static void utc_media_playlist_foreach_playlist_from_db_n(void); +static void utc_media_playlist_foreach_playlist_from_db_p(void); +static void utc_media_playlist_get_media_count_from_db_n(void); +static void utc_media_playlist_get_media_count_from_db_p(void); +static void utc_media_playlist_foreach_media_from_db_n(void); +static void utc_media_playlist_foreach_media_from_db_p(void); +static void utc_media_playlist_destroy_n(void); +static void utc_media_playlist_destroy_p(void); +static void utc_media_playlist_clone_n(void); +static void utc_media_playlist_clone_p(void); +static void utc_media_playlist_get_playlist_from_db_n(void); +static void utc_media_playlist_get_playlist_from_db_p(void); +static void utc_media_playlist_get_playlist_id_n(void); +static void utc_media_playlist_get_playlist_id_p(void); +static void utc_media_playlist_get_name_n(void); +static void utc_media_playlist_get_name_p(void); +static void utc_media_playlist_get_play_order_n(void); +static void utc_media_playlist_get_play_order_p(void); +static void utc_media_playlist_update_to_db_n(void); +static void utc_media_playlist_update_to_db_p(void); +static void utc_media_playlist_set_name_n(void); +static void utc_media_playlist_set_name_p(void); +static void utc_media_playlist_set_play_order_n(void); +static void utc_media_playlist_set_play_order_p(void); + +static void utc_media_playlist_add_media_n(void); +static void utc_media_playlist_add_media_p(void); +static void utc_media_playlist_remove_media_n(void); +static void utc_media_playlist_remove_media_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_media_playlist_insert_to_db_n, 1 }, + { utc_media_playlist_insert_to_db_p, 1 }, + { utc_media_playlist_get_playlist_count_from_db_n, 4 }, + { utc_media_playlist_get_playlist_count_from_db_p, 4 }, + { utc_media_playlist_foreach_playlist_from_db_n, 4 }, + { utc_media_playlist_foreach_playlist_from_db_p, 4 }, + { utc_media_playlist_get_media_count_from_db_n, 4 }, + { utc_media_playlist_get_media_count_from_db_p, 4 }, + { utc_media_playlist_foreach_media_from_db_n, 4 }, + { utc_media_playlist_foreach_media_from_db_p, 4 }, + { utc_media_playlist_get_playlist_from_db_n, 4 }, + { utc_media_playlist_get_playlist_from_db_p, 4 }, + { utc_media_playlist_get_playlist_id_n, 4 }, + { utc_media_playlist_get_playlist_id_p, 4 }, + { utc_media_playlist_get_name_n, 4 }, + { utc_media_playlist_get_name_p, 4 }, + { utc_media_playlist_get_play_order_n, 5 }, + { utc_media_playlist_get_play_order_p, 5 }, + { utc_media_playlist_update_to_db_n, 3 }, + { utc_media_playlist_update_to_db_p, 3 }, + { utc_media_playlist_set_name_n, 2 }, + { utc_media_playlist_set_name_p, 2 }, + { utc_media_playlist_set_play_order_n, 5 }, + { utc_media_playlist_set_play_order_p, 5 }, + { utc_media_playlist_add_media_n, 2 }, + { utc_media_playlist_add_media_p, 2 }, + { utc_media_playlist_remove_media_n, 6 }, + { utc_media_playlist_remove_media_p, 6 }, + { utc_media_playlist_clone_n, 7 }, + { utc_media_playlist_clone_p, 7 }, + { utc_media_playlist_delete_from_db_n, 8 }, + { utc_media_playlist_delete_from_db_p, 8 }, + { utc_media_playlist_destroy_n, 8 }, + { utc_media_playlist_destroy_p, 8 }, + { NULL, 0 }, +}; + +static media_playlist_h g_playlist; +static media_playlist_h g_playlist_dst; + +static filter_h g_filter; +static char *g_media_id = NULL; +static int g_playlist_id = 0; +static int g_playlist_member_id = 0; + +bool media_item_cb(media_info_h media, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_get_media_id(media, &g_media_id); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) + { + tet_printf("\n get media_id failed"); + return false; + } + + return true; +} + +bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data) +{ + g_playlist_member_id = playlist_member_id; + + tet_printf("cb - member id : %d", g_playlist_member_id); + return true; +} + +bool playlist_cb(media_playlist_h playlist, void *user_data) +{ + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + { + tet_printf("\n database connection is success"); + } + + char *condition = "MEDIA_TYPE=3"; //Music + + media_filter_create(&g_filter); + media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + //media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, "MEDIA_TITLE", MEDIA_CONTENT_COLLATE_DEFAULT); + + if(g_filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n get media_info failed"); + return; + } + + tet_printf("\n TC start END"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_media_id != NULL) + free(g_media_id); + + if(g_filter != NULL) + media_filter_destroy(g_filter); + + if(g_playlist != NULL) + media_playlist_destroy(g_playlist); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); + +} + +static void utc_media_playlist_insert_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_insert_to_db(NULL, &g_playlist); + + dts_check_eq("utc_media_playlist_insert_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_insert_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_insert_to_db("test_playlist_1", &g_playlist); + + ret = media_playlist_get_playlist_id(g_playlist, &g_playlist_id); + + dts_check_eq("utc_media_playlist_insert_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to insert the playlist"); +} + +static void utc_media_playlist_delete_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_delete_from_db(-1); + + dts_check_eq("utc_media_playlist_delete_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_delete_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_delete_from_db(g_playlist_id); + + dts_check_eq("utc_media_playlist_delete_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to delete the playlist"); +} + +static void utc_media_playlist_get_playlist_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_get_playlist_count_from_db(g_filter, NULL); + + dts_check_eq("utc_media_playlist_get_playlist_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_playlist_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int playlist_count = 0; + + ret = media_playlist_get_playlist_count_from_db(g_filter, &playlist_count); + + dts_check_eq("utc_media_playlist_get_playlist_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get playlist count"); +} + +static void utc_media_playlist_foreach_playlist_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_foreach_playlist_from_db(g_filter, NULL, NULL); + + dts_check_eq("utc_media_playlist_foreach_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_foreach_playlist_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_foreach_playlist_from_db(g_filter, playlist_cb, NULL); + + dts_check_eq("utc_media_playlist_foreach_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get list of playlist"); +} + +static void utc_media_playlist_get_media_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_get_media_count_from_db(0, g_filter, NULL); + + dts_check_eq("utc_media_playlist_get_media_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_media_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + + ret = media_playlist_get_media_count_from_db(g_playlist_id, g_filter, &media_count); + + dts_check_eq("utc_media_playlist_get_media_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the item count"); +} + +static void utc_media_playlist_foreach_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_foreach_media_from_db(0, g_filter, playlist_item_cb, NULL); + + dts_check_eq("utc_media_playlist_foreach_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_foreach_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_foreach_media_from_db(g_playlist_id, g_filter, playlist_item_cb, NULL); + + dts_check_eq("utc_media_playlist_foreach_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the list of item"); +} + +static void utc_media_playlist_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_destroy(NULL); + + dts_check_eq("utc_media_playlist_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_destroy(g_playlist_dst); + + dts_check_eq("utc_media_playlist_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destory the playlist"); +} + +static void utc_media_playlist_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_clone(&g_playlist_dst, NULL); + + dts_check_eq("utc_media_playlist_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_clone(&g_playlist_dst, g_playlist); + + dts_check_eq("utc_media_playlist_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone the playlist"); +} + +static void utc_media_playlist_get_playlist_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_h playlist; + + ret = media_playlist_get_playlist_from_db(0, g_filter, &playlist); + + dts_check_eq("utc_media_playlist_get_playlist_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_playlist_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_h playlist; + + ret = media_playlist_get_playlist_from_db(g_playlist_id, g_filter, &playlist); + + dts_check_eq("utc_media_playlist_get_playlist_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get playlist"); +} + +static void utc_media_playlist_get_playlist_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_get_playlist_id(NULL, NULL); + + dts_check_eq("utc_media_playlist_get_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_playlist_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int playlist_id = 0; + + ret = media_playlist_get_playlist_id(g_playlist, &playlist_id); + + dts_check_eq("utc_media_playlist_get_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the name of playlist"); +} + +static void utc_media_playlist_get_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + + ret = media_playlist_get_name(NULL, &name); + + dts_check_eq("utc_media_playlist_get_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + + ret = media_playlist_get_name(g_playlist, &name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_playlist_get_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the name of playlist"); +} + +static void utc_media_playlist_get_play_order_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_get_play_order(NULL, g_playlist_member_id, NULL); + + dts_check_eq("utc_media_playlist_get_play_order_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_get_play_order_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int playlist_order = 0; + + ret = media_playlist_get_play_order(g_playlist, g_playlist_member_id, &playlist_order); + + dts_check_eq("utc_media_playlist_get_play_order_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the name of playlist"); +} + +static void utc_media_playlist_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_update_to_db(NULL); + + dts_check_eq("media_playlist_update_to_db", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_update_to_db(g_playlist); + + dts_check_eq("utc_media_playlist_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update name of playlist"); +} + +static void utc_media_playlist_set_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_set_name(NULL, NULL); + + dts_check_eq("utc_media_playlist_set_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_set_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_set_name(g_playlist, "myPlaylist"); + + dts_check_eq("utc_media_playlist_set_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set name of playlist"); +} + +static void utc_media_playlist_set_play_order_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_set_play_order(NULL, g_playlist_member_id, 3); + + dts_check_eq("utc_media_playlist_set_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_set_play_order_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_set_play_order(g_playlist, g_playlist_member_id, 3); + + dts_check_eq("utc_media_playlist_set_play_order_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set name of playlist"); +} + +static void utc_media_playlist_add_media_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_add_media(NULL, g_media_id); + + dts_check_eq("utc_media_playlist_add_media_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_add_media_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_add_media(g_playlist, g_media_id); + + dts_check_eq("utc_media_playlist_add_media_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to add the item to playlist"); +} + +static void utc_media_playlist_remove_media_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + tet_printf("member id : %d", g_playlist_member_id); + ret = media_playlist_remove_media(NULL, g_playlist_member_id); + + dts_check_eq("utc_media_playlist_remove_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_playlist_remove_media_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_playlist_remove_media(g_playlist, g_playlist_member_id); + + dts_check_eq("utc_media_playlist_remove_media_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to remove the item in playlist"); +} diff --git a/TC/testcase/utc_media_tag.c b/TC/testcase/utc_media_tag.c new file mode 100755 index 0000000..0f8cd79 --- /dev/null +++ b/TC/testcase/utc_media_tag.c @@ -0,0 +1,472 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + + +static void utc_media_tag_insert_to_db_n(void); +static void utc_media_tag_insert_to_db_p(void); +static void utc_media_tag_delete_from_db_n(void); +static void utc_media_tag_delete_from_db_p(void); +static void utc_media_tag_get_tag_count_from_db_n(void); +static void utc_media_tag_get_tag_count_from_db_p(void); +static void utc_media_tag_foreach_tag_from_db_n(void); +static void utc_media_tag_foreach_tag_from_db_p(void); +static void utc_media_tag_get_media_count_from_db_n(void); +static void utc_media_tag_get_media_count_from_db_p(void); +static void utc_media_tag_foreach_media_from_db_n(void); +static void utc_media_tag_foreach_media_from_db_p(void); +static void utc_media_tag_destroy_n(void); +static void utc_media_tag_destroy_p(void); +static void utc_media_tag_clone_n(void); +static void utc_media_tag_clone_p(void); +static void utc_media_tag_update_to_db_n(void); +static void utc_media_tag_update_to_db_p(void); +static void utc_media_tag_add_media_n(void); +static void utc_media_tag_add_media_p(void); +static void utc_media_tag_remove_media_n(void); +static void utc_media_tag_remove_media_p(void); +static void utc_media_tag_set_name_n(void); +static void utc_media_tag_set_name_p(void); +static void utc_media_tag_get_tag_id_n(void); +static void utc_media_tag_get_tag_id_p(void); +static void utc_media_tag_get_name_n(void); +static void utc_media_tag_get_name_p(void); +static void utc_media_tag_get_tag_from_db_n(void); +static void utc_media_tag_get_tag_from_db_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_media_tag_insert_to_db_n, 1 }, + { utc_media_tag_insert_to_db_p, 1 }, + { utc_media_tag_delete_from_db_n, 5 }, + { utc_media_tag_delete_from_db_p, 5 }, + { utc_media_tag_get_tag_count_from_db_n, 2 }, + { utc_media_tag_get_tag_count_from_db_p, 2 }, + { utc_media_tag_foreach_tag_from_db_n, 2 }, + { utc_media_tag_foreach_tag_from_db_p, 2 }, + { utc_media_tag_get_media_count_from_db_n, 4 }, + { utc_media_tag_get_media_count_from_db_p, 4 }, + { utc_media_tag_foreach_media_from_db_n, 4 }, + { utc_media_tag_foreach_media_from_db_p, 4 }, + { utc_media_tag_destroy_n, 7 }, + { utc_media_tag_destroy_p, 7 }, + { utc_media_tag_clone_n, 6 }, + { utc_media_tag_clone_p, 6 }, + { utc_media_tag_update_to_db_n, 4 }, + { utc_media_tag_update_to_db_p, 4 }, + { utc_media_tag_add_media_n, 3 }, + { utc_media_tag_add_media_p, 3 }, + { utc_media_tag_remove_media_n, 2 }, + { utc_media_tag_remove_media_p, 2 }, + { utc_media_tag_set_name_n, 3 }, + { utc_media_tag_set_name_p, 3 }, + { utc_media_tag_get_tag_id_n, 2 }, + { utc_media_tag_get_tag_id_p, 2 }, + { utc_media_tag_get_name_n, 2 }, + { utc_media_tag_get_name_p, 2 }, + { utc_media_tag_get_tag_from_db_n, 5 }, + { utc_media_tag_get_tag_from_db_p, 5 }, + { NULL, 0 }, +}; + +static media_tag_h g_tag; +static media_tag_h g_tag_dst; +static int g_tag_id; +static char *g_media_id = NULL; + +bool media_item_cb(media_info_h media, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_get_media_id(media, &g_media_id); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) + { + tet_printf("\n get media_id failed"); + return false; + } + + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + filter_h filter; + g_tag = NULL; + g_tag_dst = NULL; + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + { + tet_printf("\n database connection is success"); + } + + char *condition = "MEDIA_TYPE=1"; //Video + + media_filter_create(&filter); + media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT); + if(filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n get media_info failed"); + return; + } + + media_filter_destroy(filter); + + tet_printf("\n TC start END"); + +} + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_tag != NULL) + media_tag_destroy(g_tag); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); +} + +bool tag_cb(media_tag_h tag, void *user_data) +{ + char *name = NULL; + + if(tag != NULL) + { + media_tag_get_name(tag, &name); + + if(name != NULL) + { + printf(" tag name : %s \n", name); + free(name); + } + + } + + return true; +} + +static void utc_media_tag_insert_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_insert_to_db(NULL, &g_tag); + + dts_check_eq("utc_media_tag_insert_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_insert_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_insert_to_db("tag_test_1", &g_tag); + media_tag_get_tag_id(g_tag, &g_tag_id); + + dts_check_eq("utc_media_tag_insert_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to insert the tag"); +} + +static void utc_media_tag_delete_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_delete_from_db(-1); + + dts_check_eq("utc_media_tag_delete_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_delete_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_delete_from_db(g_tag_id); + + dts_check_eq("utc_media_tag_delete_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to delete the name"); +} + +static void utc_media_tag_get_tag_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_get_tag_count_from_db(NULL, NULL); + + dts_check_eq("utc_media_tag_get_tag_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} +static void utc_media_tag_get_tag_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int tag_count = 0; + + ret = media_tag_get_tag_count_from_db(NULL, &tag_count); + dts_check_eq("utc_media_tag_get_tag_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get tag count"); +} + +static void utc_media_tag_foreach_tag_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_foreach_tag_from_db(NULL, NULL, NULL); + + dts_check_eq("utc_media_tag_foreach_tag_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_foreach_tag_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_foreach_tag_from_db(NULL, tag_cb, NULL); + + dts_check_eq("utc_media_tag_foreach_tag_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the tag lists"); +} + +static void utc_media_tag_get_media_count_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_get_media_count_from_db(g_tag_id, NULL, NULL); + + dts_check_eq("utc_media_tag_get_media_count_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_get_media_count_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + + ret = media_tag_get_media_count_from_db(g_tag_id, NULL, &media_count); + + dts_check_eq("utc_media_tag_get_media_count_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get media count"); +} + +static void utc_media_tag_foreach_media_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_foreach_media_from_db(g_tag_id, NULL, NULL, NULL); + + dts_check_eq("utc_media_tag_foreach_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_foreach_media_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_foreach_media_from_db(g_tag_id, NULL, media_item_cb, NULL); + + dts_check_eq("utc_media_tag_foreach_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the media list in tag"); +} + +static void utc_media_tag_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_destroy(NULL); + + dts_check_eq("utc_media_tag_destroy_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_destroy(g_tag_dst); + + dts_check_eq("utc_media_tag_destroy_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destory the tag"); +} + +static void utc_media_tag_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_clone(&g_tag_dst, NULL); + + dts_check_eq("utc_media_tag_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_clone(&g_tag_dst, g_tag); + + dts_check_eq("utc_media_tag_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone the tag"); +} + +static void utc_media_tag_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_update_to_db(NULL); + + dts_check_eq("utc_media_tag_clone_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_update_to_db(g_tag); + + dts_check_eq("utc_media_tag_clone_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update tag"); +} + +static void utc_media_tag_add_media_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_add_media(NULL, g_media_id); + + dts_check_eq("utc_media_tag_add_media_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_add_media_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_add_media(g_tag, g_media_id); + + dts_check_eq("utc_media_tag_add_media_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to add the tag to media"); +} + +static void utc_media_tag_remove_media_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_remove_media(NULL, g_media_id); + + dts_check_eq("utc_media_tag_remove_media_from_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_remove_media_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_remove_media(g_tag, g_media_id); + + dts_check_eq("utc_media_tag_remove_media_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to remove the media from tag"); + +} + +static void utc_media_tag_set_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_set_name(NULL, "myTag"); + + dts_check_eq("utc_media_tag_set_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_set_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_tag_set_name(g_tag, "myTag"); + + dts_check_eq("utc_media_tag_set_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to remove set tag name"); +} + +static void utc_media_tag_get_tag_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int tag_id = 0; + + ret = media_tag_get_tag_id(NULL, &tag_id); + + dts_check_eq("utc_media_tag_set_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_get_tag_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int tag_id = 0; + + ret = media_tag_get_tag_id(g_tag, &tag_id); + + dts_check_eq("utc_media_tag_get_tag_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get tag id"); +} + +static void utc_media_tag_get_name_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + + ret = media_tag_get_name(NULL, &name); + + dts_check_eq("utc_media_tag_get_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_get_name_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *name = NULL; + + ret = media_tag_get_name(g_tag, &name); + + if(name != NULL) + free(name); + + dts_check_eq("utc_media_tag_get_name_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the tag name"); +} + +static void utc_media_tag_get_tag_from_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_h tag; + + ret = media_tag_get_tag_from_db(0, &tag); + + dts_check_eq("utc_media_tag_get_name_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_media_tag_get_tag_from_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_h tag = NULL; + + ret = media_tag_get_tag_from_db(g_tag_id, &tag); + media_tag_destroy(tag); + + dts_check_eq("utc_media_tag_get_tag_from_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the tag"); +} diff --git a/TC/testcase/utc_media_video.c b/TC/testcase/utc_media_video.c new file mode 100755 index 0000000..b58296d --- /dev/null +++ b/TC/testcase/utc_media_video.c @@ -0,0 +1,758 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <tet_api.h> +#include <media_content.h> + +#include <stdlib.h> + +static void startup(void); +static void cleanup(void); + +void (*tet_startup)(void) = startup; +void (*tet_cleanup)(void) = cleanup; + +static void utc_video_meta_destroy_n(void); +static void utc_video_meta_destroy_p(void); +static void utc_video_meta_clone_n(void); +static void utc_video_meta_clone_p(void); +static void utc_video_meta_get_media_id_n(void); +static void utc_video_meta_get_media_id_p(void); +static void utc_video_meta_get_title_n(void); +static void utc_video_meta_get_title_p(void); +static void utc_video_meta_get_album_n(void); +static void utc_video_meta_get_album_p(void); +static void utc_video_meta_get_artist_n(void); +static void utc_video_meta_get_artist_p(void); +static void utc_video_meta_get_genre_n(void); +static void utc_video_meta_get_genre_p(void); +static void utc_video_meta_get_composer_n(void); +static void utc_video_meta_get_composer_p(void); +static void utc_video_meta_get_year_n(void); +static void utc_video_meta_get_year_p(void); +static void utc_video_meta_get_recorded_date_n(void); +static void utc_video_meta_get_recorded_date_p(void); +static void utc_video_meta_get_copyright_n(void); +static void utc_video_meta_get_copyright_p(void); +static void utc_video_meta_get_track_num_n(void); +static void utc_video_meta_get_track_num_p(void); +static void utc_video_meta_get_bit_rate_n(void); +static void utc_video_meta_get_bit_rate_p(void); +static void utc_video_meta_get_duration_n(void); +static void utc_video_meta_get_duration_p(void); +static void utc_video_meta_get_width_n(void); +static void utc_video_meta_get_width_p(void); +static void utc_video_meta_get_height_n(void); +static void utc_video_meta_get_height_p(void); +static void utc_video_meta_get_played_count_n(void); +static void utc_video_meta_get_played_count_p(void); +static void utc_video_meta_get_played_time_n(void); +static void utc_video_meta_get_played_time_p(void); +static void utc_video_meta_get_played_position_n(void); +static void utc_video_meta_get_played_position_p(void); +static void utc_video_meta_update_to_db_n(void); +static void utc_video_meta_update_to_db_p(void); +static void utc_video_meta_set_played_count_n(void); +static void utc_video_meta_set_played_count_p(void); +static void utc_video_meta_set_played_time_n(void); +static void utc_video_meta_set_played_time_p(void); +static void utc_video_meta_set_played_position_n(void); +static void utc_video_meta_set_played_position_p(void); + + +struct tet_testlist tet_testlist[] = { + { utc_video_meta_destroy_n, 5 }, + { utc_video_meta_destroy_p, 5 }, + { utc_video_meta_clone_n, 4 }, + { utc_video_meta_clone_p, 4 }, + { utc_video_meta_get_media_id_n, 1 }, + { utc_video_meta_get_media_id_p, 1 }, + { utc_video_meta_get_title_n, 1 }, + { utc_video_meta_get_title_p, 1 }, + { utc_video_meta_get_album_n, 1 }, + { utc_video_meta_get_album_p, 1 }, + { utc_video_meta_get_artist_n, 1 }, + { utc_video_meta_get_artist_p, 1 }, + { utc_video_meta_get_genre_n, 1 }, + { utc_video_meta_get_genre_p, 1 }, + { utc_video_meta_get_composer_n, 1 }, + { utc_video_meta_get_composer_p, 1 }, + { utc_video_meta_get_year_n, 1 }, + { utc_video_meta_get_year_p, 1 }, + { utc_video_meta_get_recorded_date_n, 1 }, + { utc_video_meta_get_recorded_date_p, 1 }, + { utc_video_meta_get_copyright_n, 1 }, + { utc_video_meta_get_copyright_p, 1 }, + { utc_video_meta_get_track_num_n, 1 }, + { utc_video_meta_get_track_num_p, 1 }, + { utc_video_meta_get_bit_rate_n, 1 }, + { utc_video_meta_get_bit_rate_p, 1 }, + { utc_video_meta_get_duration_n, 1 }, + { utc_video_meta_get_duration_p, 1 }, + { utc_video_meta_get_width_n, 1 }, + { utc_video_meta_get_width_p, 1 }, + { utc_video_meta_get_height_n, 1 }, + { utc_video_meta_get_height_p, 1 }, + { utc_video_meta_get_played_count_n, 1 }, + { utc_video_meta_get_played_count_p, 1 }, + { utc_video_meta_get_played_time_n, 1 }, + { utc_video_meta_get_played_time_p, 1 }, + { utc_video_meta_get_played_position_n, 1 }, + { utc_video_meta_get_played_position_p, 1 }, + { utc_video_meta_set_played_count_n, 2 }, + { utc_video_meta_set_played_count_p, 2 }, + { utc_video_meta_set_played_time_n, 2 }, + { utc_video_meta_set_played_time_p, 2 }, + { utc_video_meta_set_played_position_n, 2 }, + { utc_video_meta_set_played_position_p, 2 }, + { utc_video_meta_update_to_db_n, 3 }, + { utc_video_meta_update_to_db_p, 3 }, + { NULL, 0 }, +}; + +static video_meta_h g_video; +static video_meta_h g_video_dst; +char *g_media_id = NULL; + +bool media_item_cb(media_info_h media, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_info_get_media_id(media, &g_media_id); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_media_id == NULL)) + { + tet_printf("\n get media_id failed"); + return false; + } + + ret = media_info_get_video(media, &g_video); + if((ret != MEDIA_CONTENT_ERROR_NONE) || (g_video == NULL)) + { + tet_printf("\n get video_meta failed"); + return false; + } + + return true; +} + +static void startup(void) +{ + /* start of TC */ + tet_printf("\n TC start"); + filter_h filter; + g_video = NULL; + + int ret = media_content_connect(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n database connection is failed"); + return; + } + else + { + tet_printf("\n database connection is success"); + } + + char *condition = "MEDIA_TYPE=1"; //Video + + media_filter_create(&filter); + media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_DEFAULT); + if(filter == NULL) + { + tet_printf("\n filter create failed"); + return; + } + + ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + tet_printf("\n get media_info failed"); + return; + } + + media_filter_destroy(filter); + + tet_printf("\n TC start END"); +} + + +static void cleanup(void) +{ + /* end of TC */ + tet_printf("\n TC end"); + + if(g_media_id != NULL) + free(g_media_id); + + if(g_video != NULL) + video_meta_destroy(g_video); + + int ret = media_content_disconnect(); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + tet_printf("\n database disconnection is failed"); + else + tet_printf("\n database disconnection is success"); +} + + +/** + * @brief Negative test case of content_imageinfo_destroy() + */ +static void utc_video_meta_destroy_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_destroy(NULL); + + dts_check_eq("utc_video_meta_destroy", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + + +/** + * @brief Positive test case of content_imageinfo_destroy() + */ +static void utc_video_meta_destroy_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_destroy(g_video_dst); + + dts_check_eq("utc_video_meta_destroy", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to destroy videoinfo object"); + +} + +/** + * @brief Negative test case of imageinfo_clone() + */ +static void utc_video_meta_clone_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_clone(&g_video_dst, NULL); + + dts_check_eq("utc_video_meta_clone", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_clone() + */ +static void utc_video_meta_clone_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_clone(&g_video_dst, g_video); + + dts_check_eq("utc_video_meta_clone", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to clone videoinfo object"); +} + +static void utc_video_meta_get_media_id_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = video_meta_get_media_id(NULL, &media_id); + + dts_check_eq("utc_video_meta_get_media_id_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_media_id_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *media_id = NULL; + + ret = video_meta_get_media_id(g_video, &media_id); + + dts_check_eq("utc_video_meta_get_media_id_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get video id"); +} + +/** + * @brief Negative test case of sim_get_imageinfo_get_height() + */ +static void utc_video_meta_get_title_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *title = NULL; + + ret = video_meta_get_title(NULL, &title); + + dts_check_eq("utc_video_meta_get_title", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of sim_get_imageinfo_get_height() + */ +static void utc_video_meta_get_title_p(void) +{ + + int ret = MEDIA_CONTENT_ERROR_NONE; + char *title = NULL; + + ret = video_meta_get_title(g_video, &title); + + if(title) + free(title); + + dts_check_eq("utc_video_meta_get_title", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the title"); +} + +/** + * @brief Negative test case of imageinfo_get_description() + */ +static void utc_video_meta_get_album_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album = NULL; + + ret = video_meta_get_album(NULL, &album); + + dts_check_eq("utc_video_meta_get_album", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_get_description() + */ +static void utc_video_meta_get_album_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *album = NULL; + + ret = video_meta_get_album(g_video, &album); + + if(album) + free(album); + + dts_check_eq("utc_video_meta_get_album", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the album"); +} + +/** + * @brief Negative test case of imageinfo_get_width() + */ +static void utc_video_meta_get_artist_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *artist = NULL; + + ret = video_meta_get_artist(NULL, &artist); + + dts_check_eq("utc_video_meta_get_artist", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of imageinfo_get_width() + */ +static void utc_video_meta_get_artist_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *artist = NULL; + + ret = video_meta_get_artist(g_video, &artist); + + if(artist) + free(artist); + + dts_check_eq("utc_video_meta_get_artist", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the artist"); +} + +/** + * @brief Negative test case of video_meta_get_genre() + */ +static void utc_video_meta_get_genre_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *genre = NULL; + + ret = video_meta_get_genre(NULL, &genre); + + dts_check_eq("utc_video_meta_get_genre_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + + +/** + * @brief Positive test case of video_meta_get_genre() + */ +static void utc_video_meta_get_genre_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *genre = NULL; + + ret = video_meta_get_genre(g_video, &genre); + + if(genre) + free(genre); + + dts_check_eq("utc_video_meta_get_genre_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get genre"); +} + +/** + * @brief Negative test case of video_meta_get_composer() + */ +static void utc_video_meta_get_composer_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *composer = NULL; + + ret = video_meta_get_composer(NULL, &composer); + + dts_check_eq("utc_video_meta_get_composer_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of video_meta_get_composer() + */ +static void utc_video_meta_get_composer_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *composer = NULL; + + ret = video_meta_get_composer(g_video, &composer); + + if(composer) + free(composer); + + dts_check_eq("utc_video_meta_get_composer_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the composer"); +} + +/** + * @brief Negative test case of sim_get_imageinfo_get_height() + */ +static void utc_video_meta_get_year_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *year = NULL; + + ret = video_meta_get_year(NULL, &year); + + dts_check_eq("utc_video_meta_get_year_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + + +/** + * @brief Positive test case of sim_get_imageinfo_get_height() + */ +static void utc_video_meta_get_year_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *year = NULL; + + ret = video_meta_get_year(g_video, &year); + + if(year) + free(year); + + dts_check_eq("utc_video_meta_get_year_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get year"); +} + +/** + * @brief Negative test case of video_meta_get_recorded_date() + */ +static void utc_video_meta_get_recorded_date_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *recorded_date = NULL; + + ret = video_meta_get_recorded_date(NULL, &recorded_date); + + dts_check_eq("utc_video_meta_get_recorded_date_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Failed to get recorded_date"); +} + +/** + * @brief Positive test case of video_meta_get_recorded_date() + */ +static void utc_video_meta_get_recorded_date_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *recorded_date = NULL; + + ret = video_meta_get_year(g_video, &recorded_date); + + if(recorded_date) + free(recorded_date); + + dts_check_eq("utc_video_meta_get_recorded_date_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get recorded_date"); +} + +/** + * @brief Negative test case of video_meta_get_copyright() + */ +static void utc_video_meta_get_copyright_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *copyright = NULL; + + ret = video_meta_get_copyright(NULL, ©right); + + dts_check_eq("utc_video_meta_get_copyright_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +/** + * @brief Positive test case of video_meta_get_copyright() + */ +static void utc_video_meta_get_copyright_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *copyright = NULL; + + ret = video_meta_get_copyright(g_video, ©right); + + if(copyright) + free(copyright); + + dts_check_eq("utc_video_meta_get_copyright_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get copyright"); +} + +static void utc_video_meta_get_track_num_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *track_num = NULL; + + ret = video_meta_get_track_num(NULL, &track_num); + + dts_check_eq("utc_video_meta_get_track_num_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_track_num_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *track_num = NULL; + + ret = video_meta_get_track_num(g_video, &track_num); + + if(track_num) + free(track_num); + + dts_check_eq("utc_video_meta_get_track_num_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get track num"); +} + +static void utc_video_meta_get_bit_rate_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int bit_rate = 0; + + ret = video_meta_get_bit_rate(NULL, &bit_rate); + + dts_check_eq("utc_video_meta_get_bit_rate_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_bit_rate_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int bit_rate = 0; + + ret = video_meta_get_bit_rate(g_video, &bit_rate); + + dts_check_eq("utc_video_meta_get_bit_rate_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get the bit_rate"); +} + +static void utc_video_meta_get_duration_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int duration = 0; + + ret = video_meta_get_duration(NULL, &duration); + + dts_check_eq("utc_video_meta_get_duration", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_duration_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int duration = 0; + + ret = video_meta_get_duration(g_video, &duration); + + dts_check_eq("utc_video_meta_get_duration", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get a duration"); +} + +static void utc_video_meta_get_width_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int width = 0; + ret = video_meta_get_width(NULL, &width); + + dts_check_eq("utc_video_meta_get_width", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_width_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int width = 0; + + ret = video_meta_get_width(g_video, &width); + + dts_check_eq("utc_video_meta_get_width", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get a width"); +} + + +static void utc_video_meta_get_height_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int height = 0; + + ret = video_meta_get_height(NULL, &height); + + dts_check_eq("utc_video_meta_get_height", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_height_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int height = 0; + + ret = video_meta_get_height(g_video, &height); + + dts_check_eq("utc_video_meta_get_height", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get a height"); +} + +static void utc_video_meta_get_played_count_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int count = 0; + + ret = video_meta_get_played_count(NULL, &count); + + dts_check_eq("utc_video_meta_get_played_count_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_played_count_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int count = 0; + + ret = video_meta_get_played_count(g_video, &count); + + dts_check_eq("utc_video_meta_get_played_count_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played count"); +} + +static void utc_video_meta_get_played_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = video_meta_get_played_time(NULL, &played_time); + + dts_check_eq("utc_video_meta_get_played_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_played_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = video_meta_get_played_time(g_video, &played_time); + + dts_check_eq("utc_video_meta_get_played_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played time"); +} + +static void utc_video_meta_get_played_position_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int position = 0; + + ret = video_meta_get_played_position(NULL, &position); + + dts_check_eq("utc_video_meta_get_played_position_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_get_played_position_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int position = 0; + + ret = video_meta_get_played_position(g_video, &position); + + dts_check_eq("utc_video_meta_get_played_position_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to get played position"); +} + +static void utc_video_meta_set_played_count_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_count = 3; + + ret = video_meta_set_played_count(NULL, played_count); + + dts_check_eq("utc_video_meta_set_played_count_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_set_played_count_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_count = 3; + + ret = video_meta_set_played_count(g_video, played_count); + + dts_check_eq("utc_video_meta_set_played_count_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set played count"); +} + +static void utc_video_meta_set_played_time_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = video_meta_set_played_time(NULL, played_time); + + dts_check_eq("utc_video_meta_set_played_time_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_set_played_time_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + time_t played_time = 0; + + ret = video_meta_set_played_time(g_video, played_time); + + dts_check_eq("utc_video_meta_set_played_time_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set played time"); +} + +static void utc_video_meta_set_played_position_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_position = 0; + + ret = video_meta_set_played_position(NULL, played_position); + + dts_check_eq("video_meta_set_played_position", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_set_played_position_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int played_position = 0; + + ret = video_meta_set_played_position(g_video, played_position); + + dts_check_eq("utc_video_meta_set_played_position_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to set playedposition"); +} + +static void utc_video_meta_update_to_db_n(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_update_to_db(NULL); + + dts_check_eq("utc_video_meta_update_to_db_n", ret, MEDIA_CONTENT_ERROR_INVALID_PARAMETER, "Must return MEDIA_CONTENT_ERROR_INVALID_PARAMETER in case of invalid parameter"); +} + +static void utc_video_meta_update_to_db_p(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = video_meta_update_to_db(g_video); + + dts_check_eq("utc_video_meta_update_to_db_p", ret, MEDIA_CONTENT_ERROR_NONE, "Failed to update metadata"); +} diff --git a/TC/tet_scen b/TC/tet_scen new file mode 100644 index 0000000..03f029a --- /dev/null +++ b/TC/tet_scen @@ -0,0 +1,7 @@ +all + ^TEST +##### Scenarios for TEST ##### + +# Test scenario +TEST + :include:/testcase/tslist diff --git a/TC/tetbuild.cfg b/TC/tetbuild.cfg new file mode 100644 index 0000000..f7eda55 --- /dev/null +++ b/TC/tetbuild.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option for build operation checking +TET_BUILD_TOOL=make # build with using make command +TET_BUILD_FILE=-f Makefile # execution file (Makefile) for build +TET_API_COMPLIANT=True # use TET API in Test Case ? +TET_PASS_TC_NAME=True # report passed TC name in Journal file? diff --git a/TC/tetclean.cfg b/TC/tetclean.cfg new file mode 100644 index 0000000..02d7030 --- /dev/null +++ b/TC/tetclean.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capture option +TET_CLEAN_TOOL= make clean # clean tool +TET_CLEAN_FILE= Makefile # file for clean +TET_API_COMPLIANT=True # TET API useage +TET_PASS_TC_NAME=True # showing name , passed TC diff --git a/TC/tetexec.cfg b/TC/tetexec.cfg new file mode 100644 index 0000000..ef3e452 --- /dev/null +++ b/TC/tetexec.cfg @@ -0,0 +1,5 @@ +TET_OUTPUT_CAPTURE=True # capturing execution or not +TET_EXEC_TOOL= # ex) exec : execution tool set up/ Optional +TET_EXEC_FILE= # ex) exectool : execution file/ Optional +TET_API_COMPLIANT=True # Test case or Tool usesTET API? +TET_PASS_TC_NAME=True # showing Passed TC name ? diff --git a/debian/changelog b/debian/changelog index 81dc473..1b30821 100644..100755 --- a/debian/changelog +++ b/debian/changelog @@ -1,47 +1,261 @@ +capi-content-media-content (0.2.13-0) unstable; urgency=low + + * media_info_get_size change to use unsigned long long type + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.13-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Thu, 16 Aug 2012 20:00:00 +0900 + +capi-content-media-content (0.2.12-0) unstable; urgency=low + + * Bug fix in tag/playlist count + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.12-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Tue, 7 Aug 2012 20:00:00 +0900 + +capi-content-media-content (0.2.11-0) unstable; urgency=low + + * Create tag view + * Fix to return valid error type + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.11-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Mon, 30 Jul 2012 20:00:00 +0900 + +capi-content-media-content (0.2.10-0) unstable; urgency=low + + * Create playlist view + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.10-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 25 Jul 2012 20:00:00 +0900 + +capi-content-media-content (0.2.7-0) unstable; urgency=low + + * Packaging + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.6-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 1 Jul 2012 12:00:00 +0900 + +capi-content-media-content (0.2.6-0) unstable; urgency=low + + * bug fix of memory leak + * Modify TCs + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.6-0 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Wed, 1 Jul 2012 12:00:00 +0900 + +capi-content-media-content (0.2.0-5) unstable; urgency=low + + * bug fix of memory leak + * bug fix of getting audio meta + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.0-5 + + -- Haejeong kim <backto.kim@samsung.com> Mon, 09 Jul 2012 17:08:35 +0900 + +capi-content-media-content (0.2.0-4) unstable; urgency=low + + * Modify media_folder_update_to_db + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.0-4 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 6 Jul 2012 19:00:00 +0900 + +capi-content-media-content (0.2.0-3) unstable; urgency=low + + * bug fix of playlist + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.0-3 + + -- root <backto.kim@samsung.com> Thu, 05 Jul 2012 17:32:25 +0900 + +capi-content-media-content (0.2.0-2) unstable; urgency=low + + * added time value is time_t + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.0-2 + + -- Haejeong Kim <backto.kim@samsung.com> Wed, 20 Jun 2012 11:56:20 +0900 + +capi-content-media-content (0.2.0-1) unstable; urgency=low + + * new Media-Content released + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.2.0-1 + + -- Haejeong Kim <backto.kim@samsung.com> Mon, 18 Jun 2012 10:06:18 +0900 + +capi-content-media-content (0.1.0-20) unstable; urgency=low + + * Change DRM apis + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-20 + + -- Hyunjun Ko <zzoon.ko@samsung.com> Fri, 1 Jun 2012 15:00:00 +0900 + capi-content-media-content (0.1.0-19) unstable; urgency=low - * update for Tizen1.0 - * Git: api/media-content + * Fix dependency + * Git: slp-source.sec.samsung.net:slp/api/media-content * Tag: capi-content-media-content_0.1.0-19 - -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 19 Mar 2012 11:27:57 +0900 + -- Dongyoung Kim <dydot1.kim@samsung.com> Thu, 15 Mar 2012 14:34:54 +0900 + +capi-content-media-content (0.1.0-18) unstable; urgency=low + + * change the clone function + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-18 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Tue, 21 Feb 2012 10:24:53 +0900 capi-content-media-content (0.1.0-17) unstable; urgency=low - * chagne the code to avoid conflict - * Git: api/media-content - * Tag: capi-content-media-content_0.1.0-17 + * change the CMakefile for test code + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-17 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 20 Feb 2012 18:35:05 +0900 + +capi-content-media-content (0.1.0-16) unstable; urgency=low + + * hide the db handle to avoid conflict + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-16 - -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 20 Feb 2012 22:13:55 +0900 + -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 20 Feb 2012 18:17:15 +0900 + +capi-content-media-content (0.1.0-15) unstable; urgency=low + + * changed the query + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-15 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 15 Feb 2012 10:54:39 +0900 capi-content-media-content (0.1.0-14) unstable; urgency=low - * fixed an error - * Git: api/media-content + * fix an error for updating favorite + * Git: slp/api/media-content * Tag: capi-content-media-content_0.1.0-14 -- Dongyoung Kim <dydot1.kim@samsung.com> Tue, 14 Feb 2012 19:13:07 +0900 capi-content-media-content (0.1.0-13) unstable; urgency=low - * changed the query - * Git: api/media-content + * change the query as framework is changed + * Git: slp/api/media-content * Tag: capi-content-media-content_0.1.0-13 -- Dongyoung Kim <dydot1.kim@samsung.com> Fri, 10 Feb 2012 16:27:25 +0900 -capi-content-media-content (0.1.0-10) unstable; urgency=low +capi-content-media-content (0.1.0-12) unstable; urgency=low - * Update the version. + * change the code as framework is changed + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-12 - -- Dongyoung Kim <dydot1.kim@samsung.com> Thu, 15 Dec 2011 13:38:10 +0900 + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 18 Jan 2012 18:10:16 +0900 +capi-content-media-content (0.1.0-11) unstable; urgency=low -capi-content-media-content (0.0.1-1) unstable; urgency=low + * change the code by bug report + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-11 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 11 Jan 2012 13:49:07 +0900 + +capi-content-media-content (0.1.0-10) unstable; urgency=low + + * change the name of internal library + * Git: slp/api/media-content + * Tag: capi-content-media-content_0.1.0-10 + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 07 Dec 2011 13:25:20 +0900 + +capi-content-media-content (0.1.0-9) unstable; urgency=low + + * Replace the Error type + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-9 - * Initial release. + + -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 05 Dec 2011 13:30:20 +0900 + +capi-content-media-content (0.1.0-8) unstable; urgency=low + + * Add the log + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-8 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 30 Nov 2011 20:19:43 +0900 + +capi-content-media-content (0.1.0-7) unstable; urgency=low + + * change the code by code review + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-7 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Thu, 24 Nov 2011 15:55:16 +0900 + +capi-content-media-content (0.1.0-6) unstable; urgency=low + + * Convert SLP into TIZEN + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-6 + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 23 Nov 2011 14:00:33 +0900 + +capi-content-media-content (0.1.0-5) unstable; urgency=low + + * change the TC code + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-5 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Fri, 04 Nov 2011 16:12:19 +0900 + +capi-content-media-content (0.1.0-4) unstable; urgency=low + + * change the type of internal id + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-4 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 02 Nov 2011 18:06:27 +0900 + +capi-content-media-content (0.1.0-3) unstable; urgency=low + + * change the query for audio + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-3 + + + -- Dongyoung Kim <dydot1.kim@samsung.com> Mon, 10 Oct 2011 18:41:43 +0900 + +capi-content-media-content (0.1.0-2) unstable; urgency=low + + * change the name of function in TC + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-2 - -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 07 Dec 2011 12:46:25 +0900 + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 05 Oct 2011 18:41:24 +0900 + +capi-content-media-content (0.1.0-1) unstable; urgency=low + + * Development 1.0 + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.1.0-1 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 05 Oct 2011 13:39:25 +0900 + +capi-content-media-content (0.0.1-1) unstable; urgency=low + + * Initial Upload + * Git: slp-source.sec.samsung.net:slp/api/media-content + * Tag: capi-content-media-content_0.0.1-1 + + -- Dongyoung Kim <dydot1.kim@samsung.com> Thu, 22 Sep 2011 17:37:04 +0900 diff --git a/debian/control b/debian/control index 51b48fe..867a279 100644..100755 --- a/debian/control +++ b/debian/control @@ -1,23 +1,21 @@ Source: capi-content-media-content Section: libs Priority: extra -Maintainer: Dongyoung Kim <dydot1.kim@samsung.com>, Jongchul Park <jc0204.park@samsung.com> -Build-Depends: debhelper (>= 5), dlog-dev, libmedia-service-dev, drm-service-dev, libaul-1-dev, capi-base-common-dev -Standards-Version: 0.1 +Maintainer: Dongyoung Kim <dydot1.kim@samsung.com> +Build-Depends: debhelper (>= 5), dlog-dev, libmedia-service-dev, capi-base-common-dev, libmedia-utils-dev Package: capi-content-media-content -Section: libs Architecture: any Depends: ${shlibs:Depends}, ${misc:Depends} Description: A Media content library in Tizen Native API Package: capi-content-media-content-dev Architecture: any -Depends: capi-content-media-content (= ${Source-Version}), dlog-dev, libmedia-service-dev, drm-service-dev, libaul-1-dev, capi-base-common-dev +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-content-media-content (= ${Source-Version}), dlog-dev, libmedia-service-dev, capi-base-common-dev, libmedia-utils-dev Description: A Media content library in Tizen Native API (DEV) Package: capi-content-media-content-dbg Architecture: any -Depends: ${misc:Depends}, capi-content-media-content (= ${Source-Version}) +Depends: ${shlibs:Depends}, ${misc:Depends}, capi-content-media-content (= ${Source-Version}) Description: A Media content library in Tizen Native API (DBG) diff --git a/include/media_audio.h b/include/media_audio.h index 7208a86..183d1bd 100644..100755 --- a/include/media_audio.h +++ b/include/media_audio.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -42,14 +42,13 @@ extern "C" { * @param [in] audio The handle to audio metadata. * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre Get copy of audio metadata handle handle by calling audio_meta_clone() * @see audio_meta_clone() * @see media_info_get_audio_from_db() */ int audio_meta_destroy(audio_meta_h audio); - /** * @brief Clones audio metadata. * @details Function copies the audio metadata handle handle from source to destination. @@ -60,30 +59,43 @@ int audio_meta_destroy(audio_meta_h audio); * @param [in] src The source handle to audio metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @see audio_meta_destroy() */ -int audio_meta_clone(audio_meta_h* dst, audio_meta_h src); - +int audio_meta_clone(audio_meta_h *dst, audio_meta_h src); /** - * @brief Gets name of genre of given audio metadata. + * @brief Gets id of audio of given audio metadata. * - * @remarks @a genre_name must be released with free() by you. + * @remarks @a audio id must be released with free() by you. * * @param [in] audio The handle to audio metadata - * @param [out] genre_name The name of the genre + * @param [out] media_id The id of the audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int audio_meta_get_genre(audio_meta_h audio, char **genre_name); +int audio_meta_get_media_id(audio_meta_h audio, char **media_id); +/** + * @brief Gets title of audio of given audio metadata. + * + * @remarks @a audio title must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @param [out] title The title of the audio + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + */ +int audio_meta_get_title(audio_meta_h audio, char **title); /** - * @brief Gets name of album of given audio metadata. + * @brief Gets name of album of given audio metadata.\n + * If the value is an empty string, the method returns "Unknown". * * @remarks @a album_name must be released with free() by you. * @@ -91,14 +103,14 @@ int audio_meta_get_genre(audio_meta_h audio, char **genre_name); * @param [out] album_name The name of the album * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ int audio_meta_get_album(audio_meta_h audio, char **album_name); - /** - * @brief Gets name of artist of given audio metadata. + * @brief Gets name of artist of given audio metadata.\n + * If the value is an empty string, the method returns "Unknown". * * @remarks @a artist_name must be released with free() by you. * @@ -106,14 +118,29 @@ int audio_meta_get_album(audio_meta_h audio, char **album_name); * @param [out] artist_name The name of the artist * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ int audio_meta_get_artist(audio_meta_h audio, char **artist_name); +/** + * @brief Gets name of genre of given audio metadata.\n + * If the value is an empty string, the method returns "Unknown". + * + * @remarks @a genre_name must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @param [out] genre_name The name of the genre + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + */ +int audio_meta_get_genre(audio_meta_h audio, char **genre_name); /** - * @brief Gets name of author of given audio metadata. + * @brief Gets name of composer of given audio metadata.\n + * If the value is an empty string, the method returns "Unknown". * * @remarks @a author_name must be released with free() by you. * @@ -121,14 +148,14 @@ int audio_meta_get_artist(audio_meta_h audio, char **artist_name); * @param [out] author_name The name of the author of audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int audio_meta_get_author(audio_meta_h audio, char **author_name); - +int audio_meta_get_composer(audio_meta_h audio, char **composer_name); /** - * @brief Gets year of given audio metadata. + * @brief Gets year of given audio metadata.\n + * If the value is an empty string, the method returns "Unknown". * * @remarks @a year must be released with free() by you. * @@ -136,104 +163,94 @@ int audio_meta_get_author(audio_meta_h audio, char **author_name); * @param [out] year The year of the audio file * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int audio_meta_get_year(audio_meta_h audio, char** year); - +int audio_meta_get_year(audio_meta_h audio, char **year); /** - * @brief Gets copyright notice of given audio metadata. + * @brief Gets recorded date of given audio metadata. * - * @remarks @a copyright must be released with free() by you. + * @remarks @a recorded date must be released with free() by you. * * @param [in] audio The handle to audio metadata - * @param [out] copyright The audio copyright notice + * @param [out] recorded_date The recorded date of the audio file * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int audio_meta_get_copyright(audio_meta_h audio, char **copyright); - +int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date); /** - * @brief Gets description of given audio metadata. + * @brief Gets copyright notice of given audio metadata. * - * @remarks @a description must be released with free() by you. + * @remarks @a copyright must be released with free() by you. * * @param [in] audio The handle to audio metadata - * @param [out] description The audio description + * @param [out] copyright The audio copyright notice * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int audio_meta_get_description(audio_meta_h audio, char **description); - +int audio_meta_get_copyright(audio_meta_h audio, char **copyright); /** - * @brief Gets format of given audio metadata. - * - * @remarks @a format must be released with free() by you. + * @brief Gets track number of given audio metadata. \n + * If the value is an empty string, the method returns "Unknown". * * @param [in] audio The handle to audio metadata - * @param [out] format The audio format + * @param [out] track_num The audio track number * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_format(audio_meta_h audio, char **format); - +int audio_meta_get_track_num(audio_meta_h audio, char **track_num); /** * @brief Gets bitrate of given audio metadata in bitrate per second. * * @param [in] audio The handle to audio metadata - * @param [out] bitrate The audio bitrate in bit per second [bps]. + * @param [out] bit_rate The audio bitrate in bit per second [bps] * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_bitrate(audio_meta_h audio, int *bitrate); - +int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate); /** - * @brief Gets track number of given audio metadata. + * @brief Gets sample rate of given audio metadata. * * @param [in] audio The handle to audio metadata - * @param [out] track_num The audio track number + * @param [out] sample_rate The audio sample rate[hz] * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_track_num(audio_meta_h audio, int *track_num); - +int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate); /** - * @brief Gets track duration of given audio metadata. + * @brief Gets channel of given audio metadata. * * @param [in] audio The handle to audio metadata - * @param [out] duration The audio file duration + * @param [out] channel The channel of audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_duration(audio_meta_h audio, int *duration); - +int audio_meta_get_channel(audio_meta_h audio, int *channel); /** - * @brief Gets track rating of given audio metadata. + * @brief Gets track duration of given audio metadata. * * @param [in] audio The handle to audio metadata - * @param [out] rating The rating of audio + * @param [out] duration The audio file duration * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_rating(audio_meta_h audio, int *rating); - +int audio_meta_get_duration(audio_meta_h audio, int *duration); /** * @brief Gets number which represents how many times given audio has been played. @@ -242,10 +259,9 @@ int audio_meta_get_rating(audio_meta_h audio, int *rating); * @param [out] count_played The counter of audio played * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_count_played(audio_meta_h audio, int *count_played); - +int audio_meta_get_played_count(audio_meta_h audio, int *played_count); /** * @brief Gets the audio's played time parameter. @@ -253,761 +269,81 @@ int audio_meta_get_count_played(audio_meta_h audio, int *count_played); * starting from the beginning of the track. * * @param [in] audio The handle to audio metadata - * @param [out] time_played The elapsed time of the audio + * @param [out] played_time The elapsed time of the audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_time_played(audio_meta_h audio, int *time_played); - +int audio_meta_get_played_time(audio_meta_h audio, time_t *played_time); /** - * @brief Gets the time when audio file was added. - * - * @param [in] audio The handle to audio metadata - * @param [out] time_added The time when audio file added - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - */ -int audio_meta_get_time_added(audio_meta_h audio, time_t *time_added); - -/** - * @brief Gets audio's file size in bytes. + * @brief Gets the audio's played position parameter. + * @details Function returns audio's elapsed playback position parameter as period + * starting from the beginning of the track. * * @param [in] audio The handle to audio metadata - * @param [out] size The size of audio file in bytes. + * @param [out] played_position The elapsed time of the audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int audio_meta_get_size(audio_meta_h audio, int *size); - +int audio_meta_get_played_position(audio_meta_h audio, int *played_position); /** - * @brief Gets audio's category from desired audio metadata. + * @brief Sets the played count to audio meta handle. * * @param [in] audio The handle to audio metadata - * @param [out] category The audio category + * @param [in] played_count The played count of audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post audio_meta_update_to_db() */ -int audio_meta_get_category(audio_meta_h audio, audio_category_e *category); - +int audio_meta_set_played_count(audio_meta_h audio, int played_count); /** - * @brief Updates audio's played counter to the media database. + * @brief Sets the played time to audio meta handle. * * @param [in] audio The handle to audio metadata - * @param [in] count The new counter of audio played + * @param [in] played_time The played time of audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post audio_meta_update_to_db() */ -int audio_meta_update_count_played_to_db(audio_meta_h audio, int count); +int audio_meta_set_played_time(audio_meta_h audio, time_t played_time); /** - * @brief Updates audio's played time parameter to the media database. + * @brief Sets the played position to audio meta handle. * * @param [in] audio The handle to audio metadata - * @param [in] time The time from the beginning of audio - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - */ -int audio_meta_update_time_played_to_db(audio_meta_h audio, time_t time); - - -/** - * @} - */ - - -/** - * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_PLAYLIST_MODULE - * @{ - */ - - -/** - * @brief Iterates through the audio playlist with optional @a filter from the media database. - * @details This function gets all audio playlist handles meeting the given filter. - * The callback function will be invoked for every retrieved audio playlist. - * If NULL is passed to the filter, no filtering is applied. - - * - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke. - * @param [in] user_data User data to be passed to the callback function. - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes audio_playlist_cb(). - * @see #audio_playlist_cb - * @see media_content_connect() - * @see media_audio_filter_create() - * - */ -int audio_playlist_foreach_playlist_from_db(media_audio_filter_h filter, audio_playlist_cb callback, void *user_data); - - -/** - * @brief Iterates through the media files with optional @a filter in the given @a audio @a playlist from the media database. - * @details This function gets all media files associated with the given audio playlist and - * meeting desired filter option and calls registered callback function for - * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. - * - * @param [in] playlist The handle to audio playlist - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes media_info_cb(). - * @see #media_info_cb - * @see media_content_connect() - * @see media_audio_filter_create() - * - */ -int audio_playlist_foreach_media_from_db(audio_playlist_h playlist, media_audio_filter_h filter, media_info_cb callback, void *user_data); - - -/** - * @brief Inserts a new playlist with given name in the media database. - * - * @remark The created handle must be released with audio_playlist_destroy() by you. - * @param [in] name The name of the inserted playlist. - * @param [out] playlist A created handle to audio playlist + * @param [in] played_position The played position of audio * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see audio_playlist_delete_from_db() - * - */ -int audio_playlist_insert_to_db(const char *name, audio_playlist_h *playlist); - - -/** - * @brief Deletesthe given playlist from the media database. - * - * @param [in] playlist The handle to audio playlist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see audio_playlist_insert_to_db() - * + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post audio_meta_update_to_db() */ -int audio_playlist_delete_from_db(audio_playlist_h playlist); +int audio_meta_set_played_position(audio_meta_h audio, int played_position); /** - * @brief Gets number of media info for the given playlist present in the media database. - + * @brief Updates audio metadata which is modified attributes to the media database. * - * @param [in] playlist The handle to audio playlist - * @param [out] count The number of playlist items - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * - */ -int audio_playlist_get_media_count_from_db(audio_playlist_h playlist, int *count); - - -/** - * @brief Destroys a playlist handle. - * @details Function frees all resources related to playlist handle. This - * handle no longer can be used to perform any operation. New handle has to - * be created before next usage. - * - * @param [in] playlist The handle to audio playlist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @see audio_playlist_clone() - * @pre Get copy of playlist handle by calling audio_playlist_clone() or audio_playlist_insert_to_db() - * @see audio_playlist_clone() + * @details The function updates the given audio meta in the media database.\n + * The function should be called after any change in the attributes, to be updated to the media database.\n + * For example, after using audio_meta_set_played_count() for changing the count of the played, + * audio_meta_update_to_db() function should be called so as to update the given the attibutes in the media database. * - */ -int audio_playlist_destroy(audio_playlist_h playlist); - - -/** - * @brief Clones playlist handle. - * @details This function copies the audio playlist handle from a source to - * destination. There is no audio_playlist_create() function. The audio_playlist_h is created internally and available through - * audio playlist foreach function such as audio_playlist_foreach_playlist_from_db(). To use this handle outside of these foreach functions, - * use this function. - * - * @remark The destination handle must be released with audio_playlist_destroy() by you. - * - * @param [in] src The source handle to audio playlist - * @param [out] dst A destination handle to audio playlist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @see audio_playlist_destroy() - * @see audio_playlist_foreach_playlist_from_db() - */ -int audio_playlist_clone(audio_playlist_h *dst, audio_playlist_h src); - -/** - * @brief Gets a name of the playlist. - * - * @remarks @a playlist_name must be released with free() by you. - * - * @param [in] playlist The handle to audio playlist - * @param [out] playlist_name The playlist name - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * - */ -int audio_playlist_get_name(audio_playlist_h playlist, char **playlist_name); - - -/** - * @brief Updates the name of the given playlist in the media database. - * - * @param [in] playlist The handle to audio playlist - * @param [in] playlist_name The playlist name to set - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - */ -int audio_playlist_update_name_to_db(audio_playlist_h playlist, const char *playlist_name); - -/** - * @brief Adds a new media info to the playlist present in the media database. - * - * @param [in] playlist The handle to audio playlist - * @param [in] media The newly added media info handle - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see audio_playlist_remove_media_from_db() - */ -int audio_playlist_add_media_to_db(audio_playlist_h playlist, media_info_h media); - -/** - * @brief Removes the given @a media from the playlist present in the media database. - * - * @param [in] playlist The handle to audio playlist - * @param [in] media The handle to media info to be removed - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see audio_playlist_add_media_to_db() - */ -int audio_playlist_remove_media_from_db(audio_playlist_h playlist, media_info_h media); - -/** - * @} - */ - - -/** - * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_GENRE_MODULE - * @{ - */ - -/** - * @brief Iterates through the audio genre with optional @a filter from the media database. - * @details This function gets all audio genre handles meeting the given filter. - * The callback function will be invoked for every retrieved audio genre. - * If NULL is passed to the filter, no filtering is applied. - - * - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes audio_genre_cb(). - * @see #audio_genre_cb - * @see media_content_connect() - * @see media_audio_filter_create() - * - */ -int audio_genre_foreach_genre_from_db(media_audio_filter_h filter, audio_genre_cb callback, void *user_data); - - -/** - * @brief Iterates through the media files with optional @a filter in the given @a audio @a genre from the media database. - * @details This function gets all media files associated with the given audio genre and - * meeting desired filter option and calls registered callback function for - * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. - * - * @param [in] genre The handle to audio genre - * @param [in] filter The filter handle. - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes media_info_cb(). - * @see #media_info_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_genre_foreach_media_from_db(audio_genre_h genre, media_audio_filter_h filter, media_info_cb callback, void *user_data); - - -/** - * @brief Gets number of media info for the given genre present in the media database. - * - * @param [in] genre The handle to audio genre - * @param [out] count The count of "genre group" media information. - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - */ -int audio_genre_get_media_count_from_db(audio_genre_h genre, int *count); - - - -/** - * @brief Destroys genre handle. - * @details Function frees all resources related to genre handle. This handle - * no longer can be used to perform any operation. A new handle has to - * be created before the next use. - * - * @param [in] genre The handle to audio genre - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of genre handle by calling audio_genre_clone() - * @see audio_genre_clone() - */ -int audio_genre_destroy(audio_genre_h genre); - -/** - * @brief Clones genre handle. - * @details This function copies the audio genre handle from a source to - * destination. There is no audio_genre_create() function. The media_genre_h is created internally and available through - * audio genre foreach function such as audio_genre_foreach_genre_from_db(). To use this handle outside of these foreach functions, - * use this function. - * - * @remark The destination handle must be released with audio_genre_destroy() by you. - * - * @param [in] src The source handle to audio genre - * @param [out] dst A destination handle to audio genre - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @see audio_genre_destroy() - * @see audio_genre_foreach_genre_from_db() - */ -int audio_genre_clone(audio_genre_h *dst,audio_genre_h src); - - -/** - * @brief Gets a name of the genre. - * - * @remarks @a genre_name must be released with free() by you. - * - * @param [in] genre The handle to audio genre - * @param [out] genre_name The name of the audio genre - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - */ -int audio_genre_get_name(audio_genre_h genre, char **genre_name); - -/** - * @} - */ - - -/** - * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_ALBUM_MODULE - * @{ - */ - -/** - * @brief Iterates through the audio album with optional @a filter from the media database. - * @details This function gets all audio album handles meeting the given filter. - * The callback function will be invoked for every retrieved audio album. - * If NULL is passed to the filter, no filtering is applied. - * - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes audio_album_cb(). - * @see #audio_album_cb - * @see media_content_connect() - * @see media_audio_filter_create() - * - */ -int audio_album_foreach_album_from_db(media_audio_filter_h filter, audio_album_cb callback, void *user_data); - - -/** - * @brief Iterates through the media files with optional @a filter in the given @a audio @a album from the media database. - * @details This function gets all media files associated with the given audio album and - * meeting desired filter option and calls registered callback function for - * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. - * - * @param [in] album The handle to audio album - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes media_info_cb(). - * @see #media_info_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_album_foreach_media_from_db(audio_album_h album, media_audio_filter_h filter, media_info_cb callback, void *user_data); - - -/** - * @brief Gets number of media info for the given album present in the media database. - * - * @param [in] album The handle to audio album - * @param [out] count A count of album - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - */ -int audio_album_get_media_count_from_db(audio_album_h album, int *count); - - - - -/** - * @brief Destroys album handle. - * @details Function frees all resources related to album handle. This handle - * no longer can be used to perform any operation. A new handle has to - * be created before the next use. - * - * @param [in] album The handle to audio album - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of album handle by calling audio_album_clone() - * @see audio_album_clone() - */ -int audio_album_destroy(audio_album_h album); - -/** - * @brief Clones audio album. - * @details This function copies the audio album handle from a source to - * destination. There is no audio_album_create() function. The audio_album_h is created internally and available through - * audio album foreach function such as audio_album_foreach_album_from_db(). To use this handle outside of these foreach functions, - * use this function. - * - * @remark The destination handle must be released with audio_album_destroy() by you. - * - * @param [in] src The source handle to audio album - * @param [out] dst A destination handle to audio album - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @see audio_album_destroy() - * @see audio_album_foreach_album_from_db() - */ -int audio_album_clone(audio_album_h *dst,audio_album_h src); - - -/** - * @brief Gets a name of the album. - * - * @remarks @a album_name must be released with free() by you. - * - * @param [in] album The handle to audio album - * @param [out] album_name A name of audio album handle - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * - */ -int audio_album_get_name(audio_album_h album, char **album_name); - -/** - * @} - */ - - -/** - * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_ARTIST_MODULE - * @{ - */ - -/** - * @brief Iterates through the media files with optional @a filter from the media database. - * @details This function gets all audio artist handles meeting the given filter. - * The callback function will be invoked for every retrieved audio artist. - * If NULL is passed to the filter, no filtering is applied. - * - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes audio_artist_cb(). - * @see #audio_artist_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_artist_foreach_artist_from_db(media_audio_filter_h filter, audio_artist_cb callback, void *user_data); - - -/** - * @brief Iterates through the media files with optional @a filter in the given @a audio @artist from the media database. - * @details This function gets all media files associated with the given audio artist and - * meeting desired filter option and calls registered callback function for - * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. - - * - * @param [in] artist The handle to audio artist - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes media_info_cb(). - * @see #media_info_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_artist_foreach_media_from_db(audio_artist_h artist, media_audio_filter_h filter, media_info_cb callback, void *user_data); - - -/** - * @brief Gets number of media info for the given artist present in the media database. - * - * @param [in] artist The handle to audio artist - * @param [out] count The count of artist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - */ -int audio_artist_get_media_count_from_db(audio_artist_h artist, int *count); - -/** - * @brief Destroys artist handle. - * @details Function frees all resources related to artist handle. This handle - * no longer can be used to perform any operation. A new handle has to - * be created before the next use. - * - * @param [in] artist The handle to audio artist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of artist handle by calling audio_artist_clone() - * @see audio_artist_clone() - */ -int audio_artist_destroy(audio_artist_h artist); - -/** - * @brief Clones audio artist. - * @details This function copies the audio artist handle from a source to - * destination. There is no audio_artist_create() function. The audio_artist_h is created internally and available through - * audio artist foreach function such as audio_artist_foreach_artist_from_db(). To use this handle outside of these foreach functions, - * use this function. - - * - * @remark The destination handle must be released with audio_artist_destroy() by you. - * - * @param [in] src The source handle to audio artist - * @param [out] dst A destination handle to audio artist - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @see audio_artist_destroy() - * @see audio_artist_foreach_artist_from_db() - */ -int audio_artist_clone(audio_artist_h *dst,audio_artist_h src); - -/** - * @brief Gets a name of the artist. - * - * @remarks @a artist_name must be released with free() by you. - * - * @param [in] artist The handle to audio artist - * @param [out] artist_name A name of the audio artist handle - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - */ -int audio_artist_get_name(audio_artist_h artist, char **artist_name); - - -/** - * @} - */ - - -/** - * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_AUTHOR_MODULE - * @{ - */ - -/** - * - * @brief Iterates through the audio author with optional @a filter from the media database. - * @details This function gets all audio author handles meeting the given filter. - * The callback function will be invoked for every retrieved audio playlist. - * If NULL is passed to the filter, no filtering is applied. - * - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes audio_author_cb(). - * @see #audio_author_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_author_foreach_author_from_db(media_audio_filter_h filter, audio_author_cb callback, void *user_data); - - -/** - * @brief Iterates through the media files with optional @a filter in the given @a audio @a author from the media database. - * @details This function gets all media files associated with the given audio author and - * meeting desired filter option and calls registered callback function for - * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. - * - * - * @param [in] author The handle to audio author - * @param [in] filter The handle to audio filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes media_info_cb(). - * @see #media_info_cb - * @see media_content_connect() - * @see media_audio_filter_create() - */ -int audio_author_foreach_media_from_db(audio_author_h author, media_audio_filter_h filter, media_info_cb callback, void *user_data); - - -/** - * @brief Gets number of media info for the given author present in the media database. - * - * @param [in] author The handle to audio author - * @param [out] count The count of author + * @param [in] audio The handle to audio metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre This function requires opened connection to content service by media_content_connect(). * @see media_content_connect() + * @see audio_meta_set_played_count() + * @see audio_meta_set_played_time() + * @see audio_meta_set_played_position() */ -int audio_author_get_media_count_from_db(audio_author_h author, int *count); - - -/** - * @brief Destroys author handle. - * @details Function frees all resources related to author handle. This handle - * no longer can be used to perform any operation. A new handle has to - * be created before the next use. - * - * @param [in] author The handle to audio author - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of author handle by calling audio_author_clone() - * @see audio_author_clone() - */ -int audio_author_destroy(audio_author_h author); - - -/** - * @brief Clones audio author. - * @details This function copies the audio author handle from a source to - * destination. There is no audio_author_create() function. The audio_author_h is created internally and available through - * audio author foreach function such as audio_author_foreach_author_from_db(). To use this handle outside of these foreach functions, - * use this function. - * - * - * @param [in] src The source handle to audio author - * @param [out] dst A destination handle to audio author - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - * @post The destination handle should be deallocated by audio_author_destroy() - * @see audio_author_destroy() - * @see audio_author_foreach_author_from_db() - */ -int audio_author_clone(audio_author_h *dst,audio_author_h src); - -/** - * @brief Gets a name of the author. - * - * @remarks @a author_name must be released with free() by you. - * - * @param [in] author The handle to audio author - * @param [out] author_name The name of the "author group" handle - * @return 0 on success, otherwise a negative error value. - * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Not enough memory is available - */ -int audio_author_get_name(audio_author_h author, char **author_name); - +int audio_meta_update_to_db(audio_meta_h audio); /** * @} @@ -1018,5 +354,4 @@ int audio_author_get_name(audio_author_h author, char **author_name); } #endif - #endif /*__TIZEN_AUDIO_META_H__*/ diff --git a/include/media_bookmark.h b/include/media_bookmark.h new file mode 100755 index 0000000..5697a58 --- /dev/null +++ b/include/media_bookmark.h @@ -0,0 +1,158 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_BOOKMARK_H__ +#define __TIZEN_MEDIA_BOOKMARK_H__ + +#include <media_content_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE + * @{ + */ + +/** + * @brief Inserts a new bookmark in media on specified time offset to the media database. + * + * @param [in] media_id The id of media + * @param [in] time The bookmark time offset(in seconds) + * @param [in] thumbnail_path The thumbnail path of video bookmark. If the media type is audio, then thumbnail is null. + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_bookmark_delete_from_db() + * + */ +int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path); + +/** + * @brief Removes media bookmark from the media database. + * + * @param [in] bookmark The handle to media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_bookmark_insert_to_db() + * + */ +int media_bookmark_delete_from_db(int bookmark_id); + +/** + * @brief Gets number of bookmark with optional filter from media database. + * + * @param [in] filter The handle to media filter + * @param [out] bookmark_count The count of media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + */ +int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count); + +/** + * @brief Clones media bookmark. + * @details This function copies the media bookmark handle from a source to destination. There is no media_bookmark_create() function. + * The media_bookmark_h is created internally and available through media bookmark foreach function such as media_info_foreach_bookmark_from_db(). + * To use this handle outside of these foreach functions, use this function. + * + * @remark The destination handle must be released with media_bookmark_destroy() by you. + * + * @param [out] dst A destination handle to media bookmark + * @param [in] src The source handle to media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_bookmark_destroy() + * @see media_info_foreach_bookmark_from_db() + * + */ +int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src); + +/** + * @brief Destroys media bookmark. + * @details Function frees all resources related to bookmark handle. This handle + * no longer can be used to perform any operation. A new handle has to + * be created before the next use. + * + * @param [in] bookmark The handle to media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre Get copy of bookmark handle by calling media_bookmark_clone() + * @see media_bookmark_clone() + */ +int media_bookmark_destroy(media_bookmark_h bookmark); + +/** + * @brief Gets bookmark's id. + * + * @param [in] bookmark The handle to media bookmark + * @param [out] bookmark_id The id of media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id); + +/** + * @brief Gets bookmark's time marked parameter. + * @details Function returns time offset in milliseconds from beginning of the movie on which bookmark + * was placed. + * + * @param [in] bookmark The handle to media bookmark + * @param [out] marked_time The bookmark time offset(in milliseconds) + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t *marked_time); + +/** + * @brief Gets the media bookmark's thumbnail. + * + * @remarks thumbnail must be released with free() by you. + * + * @param [in] bookmark The handle to media bookmark + * @param [out] thumbnail_path The thumbnail path of media bookmark + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + */ +int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **thumbnail_path); + + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*__TIZEN_MEDIA_BOOKMARK_H__*/ diff --git a/include/media_content.h b/include/media_content.h index 133b41f..d26e865 100644..100755 --- a/include/media_content.h +++ b/include/media_content.h @@ -1,77 +1,78 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __TIZEN_MEDIA_CONTENT_H__
-#define __TIZEN_MEDIA_CONTENT_H__
-
-#include <media_audio.h>
-#include <media_content_type.h>
-#include <media_filter.h>
-#include <media_folder.h>
-#include <media_image.h>
-#include <media_info.h>
-#include <media_tag.h>
-#include <media_video.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @addtogroup CAPI_MEDIA_CONTENT_MODULE
- * @{
- */
-
-
-/**
- * @brief Connects to the media content service.
- * @details Any media content related function call should be invoked after this function call.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
- * @post media_content_disconnect()
- * @see media_content_disconnect()
- *
- */
-int media_content_connect(void);
-
-/**
- * @brief Disconnects from the media content service.
- * @details This function closes connection to the media content service. Any further media content related operation
- * cannot be performed after this function is called.
- *
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
- * @pre media_content_connect()
- * @see media_content_connect()
- *
- */
-int media_content_disconnect(void);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_CONTENT_H__ */
-
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_CONTENT_H__ +#define __TIZEN_MEDIA_CONTENT_H__ + +#include <media_audio.h> +#include <media_content_type.h> +#include <media_filter.h> +#include <media_folder.h> +#include <media_image.h> +#include <media_info.h> +#include <media_tag.h> +#include <media_video.h> +#include <media_group.h> +#include <media_playlist.h> +#include <media_bookmark.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup CAPI_MEDIA_CONTENT_MODULE + * @{ + */ + + +/** + * @brief Connects to the media content service. + * @details Any media content related function call should be invoked after this function call. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @post media_content_disconnect() + * @see media_content_disconnect() + * + */ +int media_content_connect(void); + +/** + * @brief Disconnects from the media content service. + * @details This function closes connection to the media content service. Any further media content related operation + * cannot be performed after this function is called. + * + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre media_content_connect() + * @see media_content_connect() + * + */ +int media_content_disconnect(void); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_CONTENT_H__ */ diff --git a/include/media_content_type.h b/include/media_content_type.h index 3907703..852b13e 100755 --- a/include/media_content_type.h +++ b/include/media_content_type.h @@ -1,454 +1,480 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __TIZEN_MEDIA_CONTENT_TYPE_H__
-#define __TIZEN_MEDIA_CONTENT_TYPE_H__
-
-#include <time.h>
-#include <tizen.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-#define ERROR_MASKL16 0xFFFF
-#define ERROR_SET(X) ((X) & ERROR_MASKL16)
-
-
-/**
-* @addtogroup CAPI_MEDIA_CONTENT_MODULE
-* @{
-*/
-
-/**
- * @ingroup CAPI_MEDIA_CONTENT_MODULE
- * @brief The enumerations of the media file format.
- */
-typedef enum
-{
- MEDIA_CONTENT_TYPE_IMAGE = 0x01 << 0, /**<The type of image */
- MEDIA_CONTENT_TYPE_VIDEO = 0x01 << 1, /**<The type of video */
- MEDIA_CONTENT_TYPE_AUDIO = 0x01 << 2, /**<The type of audio */
- MEDIA_CONTENT_TYPE_ALL = MEDIA_CONTENT_TYPE_IMAGE|MEDIA_CONTENT_TYPE_VIDEO|MEDIA_CONTENT_TYPE_AUDIO, /**< The type of all media content */
-
-} media_content_type_e;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
- * @brief The enumerations of the storage type.
- * @detail This information is used to establish where the folder is.
- */
-typedef enum
-{
- MEDIA_CONTENT_STORAGE_INTERNAL, /**< The device's internal storage */
- MEDIA_CONTENT_STORAGE_EXTERNAL, /**< The device's external storage */
- //MEDIA_CONTENT_STORAGE_WEB = 0x01<< 2,
-} media_content_storage_e;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
- * @brief The type of orientation.
- */
-typedef enum {
- MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE=0, /**< Not available*/
- MEDIA_CONTENT_ORIENTATION_NORMAL =1, /**< Normal*/
- MEDIA_CONTENT_ORIENTATION_HFLIP =2, /**< Flip horizontal*/
- MEDIA_CONTENT_ORIENTATION_ROT_180 =3, /**< Rotate 180 degrees*/
- MEDIA_CONTENT_ORIENTATION_VFLIP =4, /**< Flip vertical*/
- MEDIA_CONTENT_ORIENTATION_TRANSPOSE =5, /**< Transpose*/
- MEDIA_CONTENT_ORIENTATION_ROT_90 =6, /**< Rotate 90 degrees*/
- MEDIA_CONTENT_ORIENTATION_TRANSVERSE =7, /**< Transverse*/
- MEDIA_CONTENT_ORIENTATION_ROT_270 =8, /**< Rotate 270 degrees*/
-} media_content_orientation_e;
-
-/**
- * @ingroup CAPI_MEDIA_CONTENT_MODULE
- * @brief The enumerations of ordering.
- */
-typedef enum
-{
- MEDIA_CONTENT_SORT_NONE, /**< None order of sort*/
- MEDIA_CONTENT_SORT_BY_NAME_ASC, /**< The sort by name in ascending order*/
- MEDIA_CONTENT_SORT_BY_NAME_DESC, /**< The sort by name in descending order*/
- MEDIA_CONTENT_SORT_BY_DATE_ASC, /**< The sort by date in ascending order*/
- MEDIA_CONTENT_SORT_BY_DATE_DESC, /**< The sort by date in descending order*/
-} media_content_order_e;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE
- * @brief The category of audio.
- */
-typedef enum{
- CONTENT_AUDIO_MUSIC, /**< Music Category*/
- CONTENT_AUDIO_SOUND /**< Sound Category*/
-} audio_category_e;
-
-/**
- * @ingroup CAPI_MEDIA_CONTENT_MODULE
- * @brief The enumerations of media content error
- */
-typedef enum
-{
- MEDIA_CONTENT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */
- MEDIA_CONTENT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */
- MEDIA_CONTENT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */
- MEDIA_CONTENT_ERROR_DB_FAILED = TIZEN_ERROR_CONTENT_CLASS | 0x01, /**< DB operation failed */
- MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO = TIZEN_ERROR_CONTENT_CLASS | 0x02, /**< Only video and image info can be added to Tag */
-} media_content_error_e;
-
-
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_INFO_MODULE
- * @brief The type of searchable media info
- */
-typedef enum
-{
- MEDIA_INFO_SEARCH_NONE = 0x00, /**< No Search */
- MEDIA_INFO_SEARCH_BY_DISPLAY_NAME = 0x01 << 0, /**< The search by display name */
-
-}media_info_search_type_e;
-
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_FOLDER_MODULE
- * @brief The type of searchable media folder
- */
-typedef enum
-{
- MEDIA_FOLDER_SEARCH_NONE = 0x00, /**< No Search */
- MEDIA_FOLDER_SEARCH_BY_FOLDER_NAME = 0x01 << 0, /**< The searchable type folder name */
-}media_folder_search_type_e;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_AUDIO_MODULE
- * @brief The type of searchable media audio
- */
-typedef enum
-{
- MEDIA_AUDIO_SEARCH_NONE = 0x00, /**< No Search */
- MEDIA_AUDIO_SEARCH_BY_PLAYLIST = 0x01 << 0, /**< The searchable type of playlist */
- MEDIA_AUDIO_SEARCH_BY_ARTIST = 0x01 << 1, /**< The searchable type of artist */
- MEDIA_AUDIO_SEARCH_BY_ALBUM = 0x01 << 2, /**< The searchable type of album */
- MEDIA_AUDIO_SEARCH_BY_AUTHOR = 0x01 << 3, /**< The searchable type of author */
- MEDIA_AUDIO_SEARCH_BY_GENRE = 0x01 << 4, /**< The searchable type of genre */
-}media_audio_search_type_e;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_TAG_MODULE
- * @brief The type of searchable media tag
- */
-typedef enum
-{
- MEDIA_TAG_SEARCH_NONE = 0x00, /**< No Search */
- MEDIA_TAG_SEARCH_BY_TAG_NAME = 0x01 << 0, /**< The searchable type folder name */
-}media_tag_search_type_e;
-
-
-
-
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_INFO_MODULE
- * @brief The handle to media info filter.
- */
-typedef struct media_info_filter_s* media_info_filter_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_FOLDER_MODULE
- * @brief The handle to media folder filter.
- */
-typedef struct media_folder_filter_s* media_folder_filter_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_TAG_MODULE
- * @brief The handle to media tag filter.
- */
-typedef struct media_tag_filter_s* media_tag_filter_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_AUDIO_MODULE
- * @brief The handle to media audio filter.
- */
-typedef struct media_audio_filter_s* media_audio_filter_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FILTER_BOOKMARK_MODULE
- * @brief The handle to video bookmark filter.
- */
-typedef struct video_bookmark_filter_s* video_bookmark_filter_h;
-
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
- * @brief The handle to media info.
- */
-typedef struct media_info_s* media_info_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
- * @brief The handle to media folder.
- */
-typedef struct media_folder_s* media_folder_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE
- * @brief The handle to media tag.
- */
-typedef struct media_tag_s* media_tag_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_IMAGE_MODULE
- * @brief The handle to image metadata.
- */
-typedef struct image_meta_s* image_meta_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_VIDEO_META_MODULE
- * @brief The handle to video metadata.
- */
-typedef struct video_meta_s* video_meta_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_VIDEO_BOOKMARK_MODULE
- * @brief The handle to video bookmark.
- */
-typedef struct video_bookmark_s* video_bookmark_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE
- * @brief The handle to audio metadata.
- */
-typedef struct audio_meta_s* audio_meta_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_PLAYLIST_MODULE
- * @brief The handle to audio playlist.
- */
-typedef struct audio_playlist_s* audio_playlist_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_ALBUM_MODULE
- * @brief The handle to audio album.
- */
-typedef struct audio_album_s* audio_album_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_AUTHOR_MODULE
- * @brief The handle to audio author.
- */
-typedef struct audio_author_s* audio_author_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_GENRE_MODULE
- * @brief The handle to audio genre.
- */
-typedef struct audio_genre_s* audio_genre_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_ARTIST_MODULE
- * @brief The handle to audio artist.
- */
-typedef struct audio_artist_s* audio_artist_h;
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
- * @brief Iterates over a list of folders.
- *
- * @details This callback is called for every available media folder.\n
- *
- * @remarks To use the @a folder outside this function, copy the handle with #media_folder_clone() function.
- *
- * @param[in] folder The handle to media folder
- * @param[in] user_data The user data passed from the foreach function
-
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre media_folder_foreach_folder_from_db() will invoke this function.
- * @see media_folder_clone()
- * @see media_folder_foreach_folder_from_db()
- */
-typedef bool (*media_folder_cb)(media_folder_h folder, void *user_data);
-
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE
- * @brief Iterates over a list of media info.
- *
- * @details This callback is called for every available media info.\n
- *
- * @remarks To use the @a media outside this function, copy the handle with #media_info_clone() function.
- *
- * @param[in] media The handle to media info
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre media_tag_foreach_media_from_db(), audio_playlist_foreach_media_from_db(), audio_genre_foreach_media_from_db(),
- * audio_album_foreach_media_from_db(), audio_artist_foreach_media_from_db(), audio_author_foreach_media_from_db(),
- * media_info_foreach_media_from_db(), media_folder_foreach_media_from_db() will invoke this function.
- * @see media_info_clone()
- * @see audio_album_foreach_media_from_db()
- * @see audio_playlist_foreach_media_from_db()
- * @see audio_artist_foreach_media_from_db()
- * @see audio_author_foreach_media_from_db()
- * @see audio_genre_get_media_count_from_db()
- * @see media_tag_foreach_media_from_db()
- * @see media_info_foreach_media_from_db()
- * @see media_folder_foreach_media_from_db()
- */
-typedef bool (*media_info_cb)(media_info_h media, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE
- * @brief Iterates over a list of tags
- *
- * @details This callback is called for every tag in the obtained list of tags.\n
- *
- * @remarks To use the @a tag outside this function, copy the handle with #media_tag_clone() function.
- *
- * @param[in] tag The handle to media tag
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre media_tag_foreach_tag_from_db(), media_info_foreach_tag_from_db() will invoke this function.
- * @see media_tag_clone()
- * @see media_tag_foreach_tag_from_db()
- * @see media_info_foreach_tag_from_db()
- */
-typedef bool (*media_tag_cb)(media_tag_h tag, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_VIDEO_BOOKMARK_MODULE
- * @brief Iterates over bookmark list
- *
- * @details This callback is called for every bookmark in obtained list of bookmarks.\n
- *
- * @remarks To use the @a bookmark outside this function, copy the handle with #video_bookmark_clone() function.
- *
- * @param[in] bookmark The handle to video bookmark
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre video_bookmark_foreach_bookmark_from_db() will invoke this function.
- * @see video_bookmark_clone()
- * @see video_bookmark_foreach_bookmark_from_db()
- */
-typedef bool (*video_bookmark_cb)(video_bookmark_h bookmark, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_PLAYLIST_MODULE
- * @brief Iterates over playlist list
- *
- * @details This callback is called for every playlist in obtained list of playlists.\n
- *
- * @remarks To use the @a playlist outside this function, copy the handle with #audio_playlist_clone() function.
-
- *
- * @param[in] playlist The handle to audio playlist
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre audio_playlist_foreach_playlist_from_db() will invoke this function.
- * @see audio_playlist_clone()
- * @see audio_playlist_foreach_playlist_from_db()
- */
-typedef bool (*audio_playlist_cb)(audio_playlist_h playlist, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_GENRE_MODULE
- * @brief Iterates over genre list
- *
- * @details This callback is called for every genre in obtained list of groups.\n
- *
- * @remarks To use the @a genre outside this function, copy the handle with #audio_genre_clone() function.
- *
- * @param[in] genre The handle to audio genre
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre audio_genre_foreach_genre_from_db() will invoke this function.
- * @see audio_genre_clone()
- * @see audio_genre_foreach_genre_from_db()
- */
-typedef bool (*audio_genre_cb)(audio_genre_h genre, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_ARTIST_MODULE
- * @brief Iterates over artist list
- *
- * @details This callback is called for every artist in obtained list of groups.\n
- *
- * @remarks To use the @a artist outside this function, copy the handle with #audio_artist_clone() function.
- *
- * @param[in] artist The handle to audio artist
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre audio_artist_foreach_artist_from_db() will invoke this function.
- * @see audio_artist_clone()
- * @see audio_artist_foreach_artist_from_db()
- */
-typedef bool (*audio_artist_cb)(audio_artist_h artist, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_AUTHOR_MODULE
- * @brief Iterates over author list
- *
- * @details This callback is called for every author in obtained list of groups.\n
- *
- * @remarks To use the @a author outside this function, copy the handle with #audio_author_clone() function.
- *
- * @param[in] author The handle to audio author
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre audio_author_foreach_author_from_db() will invoke this function.
- * @see audio_author_clone()
- * @see audio_author_foreach_author_from_db()
- */
-typedef bool (*audio_author_cb)(audio_author_h author, void *user_data);
-
-/**
- * @ingroup CAPI_CONTENT_MEDIA_AUDIO_ALBUM_MODULE
- * @brief Iterates over album list
- *
- * @details This callback is called for every album in obtained list of groups.\n
- *
- * @remarks To use the @a album outside this function, copy the handle with #audio_album_clone() function.
- *
- * @param[in] album The handle to audio album
- * @param[in] user_data The user data passed from the foreach function
- * @return true to continue with the next iteration of the loop,
- * @return false to break out of the loop.
- * @pre audio_album_foreach_album_from_db() will invoke this function.
- * @see audio_album_clone()
- * @see audio_album_foreach_album_from_db()
- */
-
-typedef bool (*audio_album_cb)(audio_album_h album, void *user_data);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-
-#endif /*__TIZEN_MEDIA_CONTENT_TYPE_H__*/
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_CONTENT_TYPE_H__ +#define __TIZEN_MEDIA_CONTENT_TYPE_H__ + +#include <time.h> +#include <tizen.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#ifndef DEPRECATED_API +#define DEPRECATED_API __attribute__ ((deprecated)) +#endif + +/** +* @addtogroup CAPI_MEDIA_CONTENT_MODULE +* @{ +*/ + +/** + * @ingroup CAPI_MEDIA_CONTENT_MODULE + * @brief The enumerations of the media file format. + */ +typedef enum +{ + MEDIA_CONTENT_TYPE_IMAGE = 0, /**<The type of image */ + MEDIA_CONTENT_TYPE_VIDEO = 1, /**<The type of video */ + MEDIA_CONTENT_TYPE_SOUND = 2, /**<The type of sound */ + MEDIA_CONTENT_TYPE_MUSIC = 3, /**<The type of music */ + MEDIA_CONTENT_TYPE_OTHERS = 4, /**<The type of other */ +} media_content_type_e; + +/** + * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE + * @brief The enumerations of the storage type. + * @detail This information is used to establish where the folder is. + */ +typedef enum +{ + MEDIA_CONTENT_STORAGE_INTERNAL = 0, /**< The device's internal storage */ + MEDIA_CONTENT_STORAGE_EXTERNAL = 1, /**< The device's external storage */ +} media_content_storage_e; + +/** + * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE + * @brief The type of orientation. + */ +typedef enum { + MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE = 0, /**< Not available*/ + MEDIA_CONTENT_ORIENTATION_NORMAL = 1, /**< Normal*/ + MEDIA_CONTENT_ORIENTATION_HFLIP = 2, /**< Flip horizontal*/ + MEDIA_CONTENT_ORIENTATION_ROT_180 = 3, /**< Rotate 180 degrees*/ + MEDIA_CONTENT_ORIENTATION_VFLIP = 4, /**< Flip vertical*/ + MEDIA_CONTENT_ORIENTATION_TRANSPOSE = 5, /**< Transpose*/ + MEDIA_CONTENT_ORIENTATION_ROT_90 = 6, /**< Rotate 90 degrees*/ + MEDIA_CONTENT_ORIENTATION_TRANSVERSE = 7, /**< Transverse*/ + MEDIA_CONTENT_ORIENTATION_ROT_270 = 8, /**< Rotate 270 degrees*/ +} media_content_orientation_e; + +/** + * @ingroup CAPI_MEDIA_CONTENT_MODULE + * @brief The enumerations of ordering. + */ +typedef enum +{ + MEDIA_CONTENT_ORDER_ASC = 0, /**< ascending order*/ + MEDIA_CONTENT_ORDER_DESC = 1, /**< descending order*/ +} media_content_order_e; + +/** + * @ingroup CAPI_MEDIA_CONTENT_MODULE + * @brief The enumerations of collations. + */ +typedef enum +{ + MEDIA_CONTENT_COLLATE_DEFAULT = 0, /**< default collation BINARY */ + MEDIA_CONTENT_COLLATE_NOCASE = 1, /**< collation NOCASE, not case sensitive */ + MEDIA_CONTENT_COLLATE_RTRIM = 2, /**< collation RTRIM, trailing space characters are ignored */ +} media_content_collation_e; + +/** + * @ingroup CAPI_MEDIA_CONTENT_MODULE + * @brief The enumerations of media content error + */ +typedef enum +{ + MEDIA_CONTENT_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + MEDIA_CONTENT_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + MEDIA_CONTENT_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + MEDIA_CONTENT_ERROR_DB_FAILED = TIZEN_ERROR_CONTENT_CLASS | 0x01, /**< DB operation failed */ + MEDIA_CONTENT_ERROR_DB_BUSY = TIZEN_ERROR_CONTENT_CLASS | 0x02, /**< DB operation BUSY */ +} media_content_error_e; + +/** + * @ingroup CAPI_MEDIA_CONTENT_MODULE + * @brief The enumerations of media group + */ +typedef enum { + MEDIA_CONTENT_GROUP_DISPLAY_NAME = 0, + MEDIA_CONTENT_GROUP_TYPE, + MEDIA_CONTENT_GROUP_MIME_TYPE, + MEDIA_CONTENT_GROUP_SIZE, + MEDIA_CONTENT_GROUP_ADDED_TIME, + MEDIA_CONTENT_GROUP_MODIFIED_TIME, + MEDIA_CONTENT_GROUP_TITLE, + MEDIA_CONTENT_GROUP_ARTIST, + MEDIA_CONTENT_GROUP_GENRE, + MEDIA_CONTENT_GROUP_COMPOSER, + MEDIA_CONTENT_GROUP_YEAR, + MEDIA_CONTENT_GROUP_RECORDED_DATE, + MEDIA_CONTENT_GROUP_COPYRIGHT, + MEDIA_CONTENT_GROUP_TRACK_NUM, + MEDIA_CONTENT_GROUP_DESCRIPTION, + MEDIA_CONTENT_GROUP_LONGITUDE, + MEDIA_CONTENT_GROUP_LATIITUDE, + MEDIA_CONTENT_GROUP_ALTITUDE, + MEDIA_CONTENT_GROUP_RATING, + MEDIA_CONTENT_GROUP_AUTHOR, + MEDIA_CONTENT_GROUP_PROVIDER, + MEDIA_CONTENT_GROUP_CONTENT_NAME, + MEDIA_CONTENT_GROUP_CATEGORY, + MEDIA_CONTENT_GROUP_LOCATION_TAG, + MEDIA_CONTENT_GROUP_AGE_RATING, + MEDIA_CONTENT_GROUP_KEYWORD +} media_group_e; + +/** + * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE + * @brief The handle to media info. + */ +typedef struct media_info_s *media_info_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE + * @brief The handle to media folder. + */ +typedef struct media_folder_s *media_folder_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE + * @brief The handle to media playlist. + */ +typedef struct media_playlist_s *media_playlist_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE + * @brief The handle to media tag. + */ +typedef struct media_tag_s *media_tag_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE + * @brief The handle to media bookmark. + */ +typedef struct media_bookmark_s *media_bookmark_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_ALBUM_MODULE + * @brief The handle to media album. + */ +typedef struct media_album_s *media_album_h; + + +typedef struct media_artist_s *media_artist_h; +typedef struct media_genre_s *media_genre_h; +typedef struct media_composer_s *media_composer_h; +typedef struct media_year_s *media_year_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_IMAGE_MODULE + * @brief The handle to image metadata. + */ +typedef struct image_meta_s *image_meta_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_VIDEO_META_MODULE + * @brief The handle to video metadata. + */ +typedef struct video_meta_s *video_meta_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE + * @brief The handle to audio metadata. + */ +typedef struct audio_meta_s *audio_meta_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_FILTER_MODULE + * @brief The handle to media filter. + */ +typedef struct filter_s *filter_h; + +/** + * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE + * @brief Iterates over a list of media info. + * + * @details This callback is called for every available media info.\n + * + * @remarks To use the @a media outside this function, copy the handle with #media_info_clone() function. + * + * @param[in] media The handle to media info + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_tag_foreach_media_from_db(), media_playlist_foreach_media_from_db(), media_genre_foreach_media_from_db(), + * media_album_foreach_media_from_db(), media_artist_foreach_media_from_db(), media_composer_foreach_media_from_db(), + * media_info_foreach_media_from_db(), media_folder_foreach_media_from_db() will invoke this function. + * @see media_info_clone() + * @see media_album_foreach_media_from_db() + * @see media_playlist_foreach_media_from_db() + * @see media_artist_foreach_media_from_db() + * @see media_composer_foreach_media_from_db() + * @see media_genre_get_media_count_from_db() + * @see media_tag_foreach_media_from_db() + * @see media_info_foreach_media_from_db() + * @see media_folder_foreach_media_from_db() + */ +typedef bool (*media_info_cb)(media_info_h media, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_FOLDER_MODULE + * @brief Iterates over a list of folders. + * + * @details This callback is called for every available media folder.\n + * + * @remarks To use the @a folder outside this function, copy the handle with #media_folder_clone() function. + * + * @param[in] folder The handle to media folder + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_folder_foreach_folder_from_db() will invoke this function. + * @see media_folder_clone() + * @see media_folder_foreach_folder_from_db() + */ +typedef bool (*media_folder_cb)(media_folder_h folder, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE + * @brief Iterates over playlist list. + * + * @details This callback is called for every playlist in obtained list of playlists.\n + * + * @remarks To use the @a playlist outside this function, copy the handle with #media_playlist_clone() function. + * + * @param[in] playlist The handle to media playlist + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_playlist_foreach_playlist_from_db() will invoke this function. + * @see media_playlist_clone() + * @see media_playlist_foreach_playlist_from_db() + */ +typedef bool (*media_playlist_cb)(media_playlist_h playlist, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE + * @brief Iterates over playlist member. + * + * @details This callback is called for every media info with playlist member ID in obtained list of media info.\n + * + * @remarks To use the @a media outside this function, copy the handle with #media_info_clone() function. + * + * @param[in] playlist_member_id The ID to member of playlist + * @param[in] media The handle to media info + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_playlist_foreach_media_from_db() will invoke this function. + * @see media_info_clone() + * @see media_playlist_foreach_media_from_db() + */ +typedef bool(* playlist_member_cb)(int playlist_member_id, media_info_h media, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_TAG_MODULE + * @brief Iterates over a list of tags + * + * @details This callback is called for every tag in the obtained list of tags.\n + * + * @remarks To use the @a tag outside this function, copy the handle with #media_tag_clone() function. + * + * @param[in] tag The handle to media tag + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_tag_foreach_tag_from_db(), media_info_foreach_tag_from_db() will invoke this function. + * @see media_tag_clone() + * @see media_tag_foreach_tag_from_db() + * @see media_info_foreach_tag_from_db() + */ +typedef bool (*media_tag_cb)(media_tag_h tag, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE + * @brief Iterates over bookmark list + * + * @details This callback is called for every bookmark in obtained list of bookmarks.\n + * + * @remarks To use the @a bookmark outside this function, copy the handle with #media_bookmark_clone() function. + * + * @param[in] bookmark The handle to video bookmark + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_bookmark_foreach_bookmark_from_db() will invoke this function. + * @see media_bookmark_foreach_bookmark_from_db() + */ +typedef bool (*media_bookmark_cb)(media_bookmark_h bookmark, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_ALBUM_MODULE + * @brief Iterates over album list + * + * @details This callback is called for every album in obtained list of groups.\n + * + * @remarks To use the @a album outside this function, copy the handle with #media_album_clone() function. + * + * @param[in] album The handle to media album + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_album_foreach_album_from_db() will invoke this function. + * @see media_album_clone() + * @see media_album_foreach_album_from_db() + */ +typedef bool (*media_album_cb)(media_album_h album, void *user_data); + +typedef bool (*media_artist_cb)(const char *artist, void *user_data); +typedef bool (*media_genre_cb)(const char *genre, void *user_data); +typedef bool (*media_composer_cb)(const char *composer, void *user_data); +typedef bool (*media_year_cb)(const char *year, void *user_data); + +/** + * @ingroup CAPI_CONTENT_MEDIA_GROUP_MODULE + * @brief Iterates over media group list + * + * @details This callback is called for every group in obtained list of groups.\n + * + * @remarks You should not free group_name returned by this function. + * + * @param[in] group_name The name of media group + * @param[in] user_data The user data passed from the foreach function + * @return true to continue with the next iteration of the loop, + * @return false to break out of the loop. + * @pre media_group_foreach_group_from_db() will invoke this function. + * @see media_group_foreach_group_from_db() + */ +typedef bool (*media_group_cb)(const char *group_name, void *user_data); + +/** + * @} + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE + * @{ + * + */ +#define MEDIA_ID "MEDIA_ID" /**< media id */ +#define MEDIA_PATH "MEDIA_PATH" /**< media full path */ +#define MEDIA_DISPLAY_NAME "MEDIA_DISPLAY_NAME" /**< media base name */ +#define MEDIA_TYPE "MEDIA_TYPE" /**< media type. 0-image, 1-video, 2-sound, 3-music, 4-other*/ +#define MEDIA_MIME_TYPE "MEDIA_MIME_TYPE" /**< media mime type */ +#define MEDIA_SIZE "MEDIA_SIZE" /**< media mime size */ +#define MEDIA_ADDED_TIME "MEDIA_ADDED_TIME" /**< media added time */ +#define MEDIA_MODIFIED_TIME "MEDIA_MODIFIED_TIME" /**< media modified time */ +#define MEDIA_THUMBNAIL_PATH "MEDIA_THUMBNAIL_PATH" /**< media thumbnail path */ +#define MEDIA_TITLE "MEDIA_TITLE" /**< media title get from tag or file name */ +#define MEDIA_ALBUM "MEDIA_ALBUM" /**< media album name*/ +#define MEDIA_ARTIST "MEDIA_ARTIST" /**< media artist*/ +#define MEDIA_GENRE "MEDIA_GENRE" /**< media genre*/ +#define MEDIA_COMPOSER "MEDIA_COMPOSER" /**< media composer*/ +#define MEDIA_YEAR "MEDIA_YEAR" /**< media year*/ +#define MEDIA_RECORDED_DATE "MEDIA_RECORDED_DATE" /**< media recorded date*/ +#define MEDIA_COPYRIGHT "MEDIA_COPYRIGHT" /**< media copyright*/ +#define MEDIA_TRACK_NUM "MEDIA_TRACK_NUM" /**< media track number*/ +#define MEDIA_DESCRIPTION "MEDIA_DESCRIPTION" /**< media description*/ +#define MEDIA_BITRATE "MEDIA_BITRATE" /**< media bitrate*/ +#define MEDIA_SAMPLERATE "MEDIA_SAMPLERATE" /**< media sample rate*/ +#define MEDIA_CHANNEL "MEDIA_CHANNEL" /**< media channel*/ +#define MEDIA_DURATION "MEDIA_DURATION" /**< media duration */ +#define MEDIA_LONGITUDE "MEDIA_LONGITUDE" /**< media longitude */ +#define MEDIA_LATITUDE "MEDIA_LATITUDE" /**< media latitude */ +#define MEDIA_ALTITUDE "MEDIA_ALTITUDE" /**< media altitude */ +#define MEDIA_WIDTH "MEDIA_WIDTH" /**< media width*/ +#define MEDIA_HEIGHT "MEDIA_HEIGHT" /**< media height*/ +#define MEDIA_DATETAKEN "MEDIA_DATETAKEN" /**< media datetaken*/ +#define MEDIA_ORIENTATION "MEDIA_ORIENTATION" /**< media orientation*/ +#define MEDIA_PLAYED_COUNT "MEDIA_PLAYED_COUNT" /**< media playedcount*/ +#define MEDIA_LAST_PLAYED_TIME "MEDIA_LAST_PLAYED_TIME" /**< media last played time*/ +#define MEDIA_LAST_PLAYED_POSITION "MEDIA_LAST_PLAYED_POSITION" /**< media last played position of file*/ +#define MEDIA_RATING "MEDIA_RATING" /**< media rating*/ +#define MEDIA_FAVOURITE "MEDIA_FAVORITE" /**< 0-not favourite, 1-favourite*/ +#define MEDIA_AUTHOR "MEDIA_AUTHOR" /**< media authore*/ +#define MEDIA_PROVIDER "MEDIA_PROVIDER" /**< media provider*/ +#define MEDIA_CONTENT_NAME "MEDIA_CONTENT_NAME" /**< media content name*/ +#define MEDIA_CATEGORY "MEDIA_CATEGORY" /**< media category*/ +#define MEDIA_LOCATION_TAG "MEDIA_LOCATION_TAG" /**< media location tag*/ +#define MEDIA_AGE_RATING "MEDIA_AGE_RATING" /**< media age rating*/ +#define MEDIA_KEYWORD "MEDIA_KEYWORD" /**< media keyword*/ +#define MEDIA_IS_DRM "MEDIA_IS_DRM" /**< is drm. 0-not drm, 1-drm*/ +#define MEDIA_STORAGE_TYPE "MEDIA_STORAGE_TYPE" /**< media storage. 0-internal storage, 1-external storage*/ +/** + * @} + */ + + +/** + + * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE + * @{ + */ +#define FOLDER_ID "FOLDER_ID" /**< folder id */ +#define FOLDER_PATH "FOLDER_PATH" /**< folder full path */ +#define FOLDER_NAME "FOLDER_NAME" /**< folder base name */ +#define FOLDER_MODIFIED_TIME "FOLDER_MODIFIED_TIME" /**< folder modified time */ +#define FOLDER_STORAGE_TYPE "FOLDER_STORAGE_TYPE" /**< folder storage. 0-internal storage, 1-external storage*/ + +/** + * @} + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE + * @{ + */ +#define PLAYLIST_NAME "PLAYLIST_NAME" /**< playlist name */ +#define PLAYLIST_MEMBER_ORDER "PLAYLIST_MEMBER_ORDER" /**< playlist name */ +#define PLAYLIST_MEDIA_COUNT "PLAYLIST_MEDIA_COUNT" /**< media count in playlist view */ + +/** + * @} + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_TAG_MODULE + * @{ + */ +#define TAG_NAME "TAG_NAME" /**< tag name */ +#define TAG_MEDIA_COUNT "TAG_MEDIA_COUNT" /**< media count in tag view */ + +/** + * @} + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_BOOKMARK_MODULE + * @{ + */ +#define BOOKMARK_MARKED_TIME "BOOKMARK_MARKED_TIME" /**< bookmark marked time */ + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + + +#endif /*__TIZEN_MEDIA_CONTENT_TYPE_H__*/ diff --git a/include/media_filter.h b/include/media_filter.h index 400e968..0592961 100644..100755 --- a/include/media_filter.h +++ b/include/media_filter.h @@ -1,729 +1,166 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __TIZEN_MEDIA_FILTER_H__
-#define __TIZEN_MEDIA_FILTER_H__
-
-#include <media_content_type.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FILTER_INFO_MODULE
- * @{
- */
-
-/**
- * @brief Creates a media info filter handle.
- * @details This function creates a media info filter handle. The handle can be
- * used to get filtered information based on filter properties i.e. offset, count,search type, search keyword,
- * media type and order.
- *@remarks The @a filter handle must be released with media_info_filter_destroy() by you.
- * @param[out] filter A handle to media info filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @see media_info_filter_destroy()
- *
- */
-int media_info_filter_create(media_info_filter_h* filter);
-
-/**
- * @brief Destroys a media info filter handle.
- * @details The function frees all resources related to the media info filter handle. The filter
- * handle no longer can be used to perform any operation. A new filter handle
- * has to be created before the next usage.
- *
- * @param[in] filter The handle to media info filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- *
- */
-int media_info_filter_destroy(media_info_filter_h filter);
-
-
-/**
- * @brief Set the media info filter's offset and count.
- * @details This function set the @a offset and @a count for the given filter used to limit number of items returned.
- * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions.
- *
- * @param[in] filter The handle to media info filter
- * @param[in] offset The start position of the given filter(Starting from zero).
- * @param[in] count The number of items to be searched with respect to offset
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_set_offset(media_info_filter_h filter, int offset, int count);
-
-
-/**
- * @brief Set the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @param[in] filter The handle to media info filter
- * @param[in] search_type The type which user want to search. e.g. display name
- * @param[in] search_keyword The keyword which user want to search.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_set_search_keyword(media_info_filter_h filter, media_info_search_type_e search_type, const char *search_keyword);
-
-
-/**
- * @brief Set the media info filter's content order either descending or ascending.
- *
- * @param[in] filter The media info filter handle
- * @param[in] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_set_order(media_info_filter_h filter, media_content_order_e order);
-
-
-/**
- * @brief Set the media info filter's content type.
- *
-
- *
- * @param[in] filter The handle to Media Info filter.
- * @param[in] media_type The type of the content(#media_content_type_e) \n
- * To allow searching over different content types, you should use bitwise 'OR' operator to compose 'type' parameter.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_set_media_type(media_info_filter_h filter,int media_type);
-
-
-/**
- * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
- *
- * @param[in] filter The handle to Media Info filter
- * @param[out] offset The start position of the given filter(Starting from zero).
- * @param[out] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_get_offset(media_info_filter_h filter, int* offset, int* count);
-
-
-/**
- * @brief Gets the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @remarks @a search_keyword must be released with free() by you.
- * @param[in] filter The handle to media info filter
- * @param[out] search_type The type of search
- * @param[out] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_get_search_keyword(media_info_filter_h filter,media_info_search_type_e* search_type, char **search_keyword);
-
-
-/**
- * @brief Gets the media info filter's content order.
- * @details This function gets the @a order for given @a filter.
- *
- * @param[in] filter The handle to media info filter
- * @param[out] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_get_order(media_info_filter_h filter, media_content_order_e* order);
-
-
-/**
- * @brief Gets the media info filter's content type.
- * @details This function gets the content type (#media_content_type_e) for given filter
- *
- *
- * @param[in] filter The handle to media info filter
- * @param[out] type The type of the media content(#media_content_type_e) \n
- * To allow searching over different content types, you should use bitwise 'OR' operator to compose 'type' parameter.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_info_filter_create()
- * @see media_info_filter_destroy()
- */
-int media_info_filter_get_media_type(media_info_filter_h filter,int* type);
-
-/**
- * @}
- */
-
-
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FILTER_FOLDER_MODULE
- * @{
- */
-
-
-/**
- * @brief Creates a media folder filter handle.
- * @details This function creates a media folder filter handle. The handle can be
- * used to get filtered information based on filter properties i.e. offset, count, search type, search keyword
- * and order.
- *
- * @remarks The @a filter handle must be released with media_info_filter_destroy() by you.
- * @param[out] filter A handle to media folder filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @see media_folder_filter_destroy(),
- *
- */
-int media_folder_filter_create(media_folder_filter_h* filter);
-
-/**
- * @brief Destroys a media media folder filter
- * @details The function frees all resources related to the media folder filter handle. The filter
- * handle no longer can be used to perform any operation. A new filter handle
- * has to be created before the next usage.
- *
- * @param[in] filter The handle to media folder filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- *
- */
-
-int media_folder_filter_destroy(media_folder_filter_h filter);
-
-
-/**
- * @brief Set the media folder filter's offset and count.
- * @details This function set the @a offset and @a count for the given filter used to limit number of items returned.
- * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions.
- *
- * @param[in] filter The handle to media folder filter
- * @param[in] offset The start position of the given filter(Starting from zero).
- * @param[in] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_set_offset(media_folder_filter_h filter, int offset, int count);
-
-
-/**
- * @brief Set the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @param[in] filter The handle to media folder filter
- * @param[in] search_type The type which user want to search.
- * @param[in] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_set_search_keyword(media_folder_filter_h filter,media_folder_search_type_e search_type,const char *search_keyword);
-
-
-/**
- * @brief Set the media folder filter's content order either descending or ascending.
- *
- * @param[in] filter the handle to media folder filter
- * @param[in] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_set_order(media_folder_filter_h filter, media_content_order_e order);
-
-
-
-/**
- * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
- *
- * @param[in] filter The handle to media folder filter
- * @param[out] offset The start position of the given filter(Starting from zero).
- * @param[out] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_get_offset(media_folder_filter_h filter, int* offset, int* count);
-
-
-/**
- * @brief Gets the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @remarks search_keyword must be released with free() by you.
- * @param[in] filter The handle to media folder filter
- * @param[out] search_type The type of search
- * @param[out] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_get_search_keyword(media_folder_filter_h filter,media_folder_search_type_e* search_type, char **search_keyword);
-
-
-/**
- * @brief Gets the media folder filter's content order.
- * @details This function gets the @a order for given @a filter.
- *
- * @param[in] filter The handle to media folder filter
- * @param[out] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_filter_create()
- * @see media_folder_filter_destroy()
- */
-int media_folder_filter_get_order(media_folder_filter_h filter, media_content_order_e* order);
-
-
-
-/**
- * @}
- */
-
-
-
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FILTER_AUDIO_MODULE
- * @{
- */
-
-
-
-/**
- * @brief Creates a audio filter handle.
- * @details This function creates a #media_audio_filter_h filter handle. The handle can be
- * used to get filtered information based on filter properties i.e. offset, count, search keyword
- * and order.
- *
- * @param[out] filter A handle to media audio filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @see media_audio_filter_destroy(),
- *
- */
-int media_audio_filter_create(media_audio_filter_h* filter);
-
-/**
- * @brief Destroys a media audio filter handle.
- * @details The function frees all resources related to the media audio filter handle. The filter
- * handle no longer can be used to perform any operation. A new filter handle
- * has to be created before the next usage.
- *
- * @param[in] filter The handle to media audio filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- *
- */
-
-int media_audio_filter_destroy(media_audio_filter_h filter);
-
-
-/**
- * @brief Set the media audio filter's offset and count.
- * @details This function set the @a offset and @a count for the given filter used to limit number of items returned.
- * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions.
- *
- * @param[in] filter The handle to media audio filter
- * @param[in] offset The start position of the given filter (Starting from zero).
- * @param[in] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_set_offset(media_audio_filter_h filter, int offset, int count);
-
-
-/**
- * @brief Set the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @param[in] filter The handle to media audio filter
- * @param[in] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_set_search_keyword(media_audio_filter_h filter,media_audio_search_type_e search_type,const char *search_keyword);
-
-
-/**
- * @brief Set the media audio filter's content order either descending or ascending.
- *
- * @param[in] filter The handle to media audio filter
- * @param[in] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_set_order(media_audio_filter_h filter, media_content_order_e order);
-
-
-
-
-/**
- * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
- *
- * @param[in] filter The handle to media audio filter
- * @param[out] offset The start position of the given filter (Starting from zero).
- * @param[out] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_get_offset(media_audio_filter_h filter, int* offset, int* count);
-
-
-/**
- * @brief Gets the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @remarks search_keyword must be released with free() by you.
- * @param[in] filter The handle to media audio filter
- * @param[out] search_type The type of search
- * @param[out] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_get_search_keyword(media_audio_filter_h filter,media_audio_search_type_e* search_type,char **search_keyword);
-
-
-/**
- * @brief Gets the media audio filter's content order.
- * @details This function gets the @a order for given @a filter.
- *
- * @param[in] filter The handle to media audio filter
- * @param[out] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_audio_filter_create()
- * @see media_audio_filter_destroy()
- */
-int media_audio_filter_get_order(media_audio_filter_h filter, media_content_order_e* order);
-
-
-/**
- * @}
- */
-
-
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FILTER_TAG_MODULE
- * @{
- */
-
-
-/**
- * @brief Creates a media tag filter handle.
- * @details This function creates a #media_tag_filter_h filter handle. The handle can be
- * used to get filtered information based on filter properties i.e. offset, count, search keyword
- * and order.
- *
- * @param[out] filter A handle to media tag filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @see media_tag_filter_destroy(),
- *
- */
-int media_tag_filter_create(media_tag_filter_h* filter);
-
-/**
- * @brief Destroys a media tag filter handle.
- * @details The function frees all resources related to the tag filter handle. The filter
- * handle no longer can be used to perform any operation. A new filter handle
- * has to be created before the next usage.
- *
- * @param[in] The handle to media tag filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- *
- */
-
-int media_tag_filter_destroy(media_tag_filter_h filter);
-
-/**
- * @brief Set the media tag filter's offset and count.
- * @details This function set the @a offset and @a count for the given filter used to limit number of items returned.
- * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions.
- *
- *
- * @param[in] filter The handle to media tag filter
- * @param[in] offset The start position of the given filter(Starting from zero).
- * @param[in] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_set_offset(media_tag_filter_h filter, int offset, int count);
-
-
-/**
- * @brief Set the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @param[in] filter The handle to media tag filter
- * @param[in] search_type The type which user want to search.
- * @param[in] search_keyword The keyword which user want to search.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_set_search_keyword(media_tag_filter_h filter,media_tag_search_type_e search_type,const char *search_keyword);
-
-
-/**
- * @brief Set the media tag filter's content order either descending or ascending.
- *
- * @param[in] filter The handle to media tag filter
- * @param[in] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_set_order(media_tag_filter_h filter, media_content_order_e order);
-
-
-
-/**
- * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
- *
- * @param[in] filter The handle to media tag filter
- * @param[out] offset The start position of the given filter(Starting from zero).
- * @param[out] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_get_offset(media_tag_filter_h filter, int* offset, int* count);
-
-
-/**
- * @brief Gets the @a search @a keyword and @a search @a type for given @a filter.
- *
- * @remarks search_keyword must be released with free() by you.
- * @param[in] filter The handle to media tag filter
- * @param[out] search_type The type of search
- * @param[out] search_keyword The keyword which user want to search
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_get_search_keyword(media_tag_filter_h filter, media_tag_search_type_e *search_type,char **search_keyword);
-
-
-/**
- * @brief Gets the media tag filter's content order.
- * @details This function gets the @a order for given @a filter.
- *
- * @param[in] filter The handle to media tag filter
- * @param[out] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_filter_create()
- * @see media_tag_filter_destroy()
- */
-int media_tag_filter_get_order(media_tag_filter_h filter, media_content_order_e* order);
-
-/**
- * @}
- */
-
-
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FILTER_BOOKMARK_MODULE
- * @{
- */
-
-
-
-/**
- * @brief Creates a video bookmark filter handle.
- * @details This function creates a #video_bookmark_filter_h filter handle. The handle can be
- * used to get filtered information based on filter properties i.e. offset, count and order.
- *
- * @param[out] filter A handle to video bookmark filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @see video_bookmark_filter_destroy(),
- *
- */
-int video_bookmark_filter_create(video_bookmark_filter_h* filter);
-
-/**
- * @brief Destroys a video bookmark filter handle.
- * @details The function frees all resources related to the bookmark filter handle. The filter
- * handle no longer can be used to perform any operation. A new filter handle
- * has to be created before the next usage.
- *
- * @param[in] filter The handle to video bookmark filter
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see video_bookmark_filter_create()
- *
- */
-
-int video_bookmark_filter_destroy(video_bookmark_filter_h filter);
-
-/**
- * @brief Set the video bookmark filter's offset.
- * @details This function set the offset and count for the given bookmark filter used to limit number of items returned.
- *
- * @param[in] filter The handle to video bookmark filter
- * @param[in] offset The start position of the given filter (Starting from zero).
- * @param[in] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see video_bookmark_filter_create()
- * @see video_bookmark_filter_destroy()
- */
-int video_bookmark_filter_set_offset(video_bookmark_filter_h filter, int offset, int count);
-
-
-/**
- * @brief Set the video bookmark filter's content order either descending or ascending.
- *
- * @param[in] filter The handle to video bookmark filter
- * @param[in] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see video_bookmark_filter_create()
- * @see video_bookmark_filter_destroy()
- */
-int video_bookmark_filter_set_order(video_bookmark_filter_h filter, media_content_order_e order);
-
-
-/**
- * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned.
- *
- * @param[in] filter The handle to video bookmark filter
- * @param[out] offset The start position of the given filter (Starting from zero).
- * @param[out] count The number of items to be searched with respect to offset.
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see video_bookmark_filter_create()
- * @see video_bookmark_filter_destroy()
- */
-int video_bookmark_filter_get_offset(video_bookmark_filter_h filter, int* offset, int* count);
-
-
-/**
- * @brief Gets the video bookmark filter's content order.
- * @details This function gets the @a order for given @a filter.
- *
- * @param[in] filter The handle to video bookmark filter
- * @param[out] order The search order type
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see video_bookmark_filter_create()
- * @see video_bookmark_filter_destroy()
- */
-int video_bookmark_filter_get_order(video_bookmark_filter_h filter, media_content_order_e* order);
-
-/**
- * @}
- */
-
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_FILTER_H__ */
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_FILTER_H__ +#define __TIZEN_MEDIA_FILTER_H__ + +#include <media_content_type.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_FILTER_MODULE + * @{ + */ + +/** + * @brief Creates a media filter handle. + * @details This function creates a media filter handle. The handle can be + * used to get filtered information based on filter properties i.e. offset, count, condition for searching and order. + * @remarks The @a filter handle must be released with media_info_filter_destroy() by you. + * @param[out] filter A handle to media filter + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_filter_destroy() + * + */ +int media_filter_create(filter_h *filter); + +/** + * @brief Destroys a media filter handle. + * @details The function frees all resources related to the media filter handle. The filter + * handle no longer can be used to perform any operation. A new filter handle + * has to be created before the next usage. + * + * @param[in] filter The handle to media filter + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * + */ +int media_filter_destroy(filter_h filter); + +/** + * @brief Set the media filter's offset and count. + * @details This function set the @a offset and @a count for the given filter used to limit number of items returned. + * For example, if you set the @a offset as 10 and @a count as 5, then only searched data from 10 to 14 will be returned when the filter is used with foreach functions. + * + * @param[in] filter The handle to media filter + * @param[in] offset The start position of the given filter(Starting from zero). + * @param[in] count The number of items to be searched with respect to offset + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_set_offset(filter_h filter, int offset, int count); + +/** + * @brief Set the @a condition for given @a filter. + * + * @param[in] filter The handle to media filter + * @param[in] condition The condition which is used WHERE clause on a query + * @param[in] collate_type The collate type for comparing two strings + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_set_condition(filter_h filter, const char *condition, media_content_collation_e collate_type); + +/** + * @brief Set the media filter's content @a order and @a order @a keyword either descending or ascending. + * + * @param[in] filter The handle to media filter + * @param[in] order_type The search order type + * @param[in] order_keyword The search order keyword + * @param[in] collate_type The collate type for comparing two strings + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_set_order(filter_h filter, media_content_order_e order_type, const char *order_keyword, media_content_collation_e collate_type); + +/** + * @brief Gets the @a offset and @a count for the given @a filter used to limit number of items returned. + * + * @param[in] filter The handle to Media filter + * @param[out] offset The start position of the given filter(Starting from zero) + * @param[out] count The number of items to be searched with respect to offset + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_get_offset(filter_h filter, int *offset, int *count); + +/** + * @brief Get the @a condition for given @a filter. + * + * @remarks @a condition must be released with free() by you. + * @param[in] filter The handle to media info filter + * @param[out] condition The condition which is used WHERE clause on a query + * @param[out] collate_type The collate type for comparing two strings + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_get_condition(filter_h filter, char **condition, media_content_collation_e *collate_type); + +/** + * @brief Get the media filter's content @a order and @a order @a keyword either descending or ascending. + * + * @remarks @a order_keyword must be released with free() by you. + * @param[in] filter The handle to media filter + * @param[out] order_type The search order type + * @param[out] order_keyword The search order keyword + * @param[out] collate_type The collate type for comparing two strings + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * @see media_filter_destroy() + */ +int media_filter_get_order(filter_h filter, media_content_order_e* order_type, char **order_keyword, media_content_collation_e *collate_type); + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_FILTER_H__ */ diff --git a/include/media_folder.h b/include/media_folder.h index 6aeb01f..38f7899 100644..100755 --- a/include/media_folder.h +++ b/include/media_folder.h @@ -1,192 +1,269 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __TIZEN_MEDIA_FOLDER_H__
-#define __TIZEN_MEDIA_FOLDER_H__
-
-
-#include <media_content_type.h>
-
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE
- * @{
- */
-
-/**
- * @brief Iterates through all available media folders from the media database.
- * @details This function gets all media folder handles meeting the given
- * @a filter. The @a callback function will be invoked for every retrieved
- * folder. If NULL is passed to the @a filter, no filtering is applied.
- *
- * @param[in] filter The handle to media folder filter
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @pre This function requires opened connection to content service by media_content_connect().
- * @pre A filter handle has to be created by calling media_folder_filter_create()
- * @post This function invokes media_folder_cb()
- * @see media_content_connect()
- * @see #media_folder_cb
- * @see media_folder_filter_create()
- */
-int media_folder_foreach_folder_from_db(media_folder_filter_h filter, media_folder_cb callback, void *user_data);
-
-/**
- * @brief Iterates through the media files with optional @a filter in the given @a folder from the media database.
- * @details This function gets all media files associated with the given folder and
- * meeting desired filter option and calls registered callback function for
- * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied.
- *
- * @param[in] folder The handle to media folder
- * @param[in] filter The handle to media info filter
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @pre This function requires opened connection to content service by media_content_connect().
- * @post This function invokes media_info_cb()
- * @see #media_info_cb
- * @see media_content_connect()
- * @see media_folder_filter_create()
- */
-int media_folder_foreach_media_from_db(media_folder_h folder, media_info_filter_h filter, media_info_cb callback, void *user_data);
-
-
-/**
- * @brief Gets the number of media files for the passed @a type in the given @a folder from the media database.
- *
- * @param[in] folder The handle to media folder
- * @param[in] type The type of media content. \n To allow searching over different content types, you should use bitwise 'OR' operator to compose @a type.
- * @param[out] count The count of media folder items
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- *
- */
-int media_folder_get_media_count_from_db(media_folder_h folder, media_content_type_e type, int *count);
-
-/**
- * @brief Clones the media folder.
- * @details This function copies the media folder handle from a source to
- * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through
- * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions,
- * use this function.
- * @remark The destination handle must be released with media_folder_destroy() by you.
- * @param[out] dst A destination handle to media folder
- * @param[in] src The source handle to media folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_folder_destroy()
- * @see media_folder_foreach_folder_from_db()
- */
-int media_folder_clone(media_folder_h* dst, media_folder_h src);
-
-
-/**
- * @brief Destroys the media folder.
- * @details The function frees all resources related to the folder handle. This handle
- * no longer can be used to perform any operation. A new handle has to
- * be created before the next use.
- *
- * @param[in] folder The handle to media folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre A copy of the media folder handle created by calling media_folder_clone()
- * @see media_folder_clone()
- */
-int media_folder_destroy(media_folder_h folder);
-
-
-/**
- * @brief Gets the absolute path to the folder.
- *
- * @remarks @a path must be released with free() by you.
- *
- * @param[in] folder The handle to media folder
- * @param[out] path The path of the media folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- *
- */
-int media_folder_get_path(media_folder_h folder, char **path);
-
-/**
- * @brief Gets the folder name.
- *
- * @remarks @a folder_name must be released with free() by you.
- *
- * @param[in] folder The handle to media folder
- * @param[out] folder_name The name of the media folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- *
- */
-int media_folder_get_name(media_folder_h folder, char **folder_name);
-
-/**
- * @brief Gets the folder storage type.
- *
- * @param[in] folder The handle to media folder
- * @param[out] storage_type The storage type of the media folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- *
- */
-int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type);
-
-/**
- * @brief Gets the modified date of the folder.
- *
- * @param[in] folder The handle to media folder
- * @param[out] date The modified date of folder
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- *
- */
-int media_folder_get_date_modified(media_folder_h folder, time_t *date);
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_FOLDER_H__ */
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_FOLDER_H__ +#define __TIZEN_MEDIA_FOLDER_H__ + + +#include <media_content_type.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_FOLDER_MODULE + * @{ + */ + +/** + * @brief Gets the number of folder for the passed @a filter from the media database. + * + * @param[in] filter The handle to filter. \n To allow searching over different content types, you should use @a filter_h. + * @param[out] folder_count The count of media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count); + +/** + * @brief Iterates through available media folders with optional @a filter from the media database. + * @details This function gets media folder handles meeting the given + * @a filter. The @a callback function will be invoked for every retrieved + * folder. If NULL is passed to the @a filter, no filtering is applied. + * + * @param[in] filter The handle to media folder filter + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @pre A filter handle has to be created by calling media_folder_filter_create() + * @post This function invokes media_folder_cb() + * @see media_content_connect() + * @see #media_folder_cb + * @see media_filter_create() + */ +int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data); + +/** + * @brief Gets the number of media files for the passed @a filter in the given @a folder from the media database. + * + * @param[in] folder_id The ID of media folder + * @param[in] filter The filter of media content + * @param[out] media_count The count of media folder items + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count); + +/** + * @brief Iterates through the media files with optional @a filter in the given @a folder from the media database. + * @details This function gets all media files associated with the given folder and + * meeting desired filter option and calls registered callback function for + * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied. + * + * @param[in] folder_id The ID of media folder + * @param[in] filter The handle to media info filter + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_info_cb() + * @see #media_info_cb + * @see media_content_connect() + * @see media_folder_filter_create() + */ +int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data); + +/** + * @brief Clones the media folder. + * @details This function copies the media folder handle from a source to + * destination. There is no media_folder_create() function. The media_folder_h is created internally and available through + * media folder foreach function such as media_folder_foreach_folder_from_db(). To use this handle outside of these foreach functions, + * use this function. + * @remark The destination handle must be released with media_folder_destroy() by you. + * @param[out] dst A destination handle to media folder + * @param[in] src The source handle to media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_folder_destroy() + * @see media_folder_foreach_folder_from_db() + */ +int media_folder_clone(media_folder_h *dst, media_folder_h src); + +/** + * @brief Destroys the media folder. + * @details The function frees all resources related to the folder handle. This handle + * no longer can be used to perform any operation. A new handle has to + * be created before the next use. + * + * @param[in] folder The handle to media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre A copy of the media folder handle created by calling media_folder_clone() + * @see media_folder_clone() + */ +int media_folder_destroy(media_folder_h folder); + +/** + * @brief Gets media folder's ID. + * + * @remarks @a folder_id must be released with free() by you. + * + * @param [in] folder The handle to media folder + * @param [out] folder_id The ID of media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_folder_get_folder_id(media_folder_h folder, char **folder_id); + +/** + * @brief Gets the absolute path to the folder. + * + * @remarks @a path must be released with free() by you. + * + * @param[in] folder The handle to media folder + * @param[out] path The path of the media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_folder_get_path(media_folder_h folder, char **path); + +/** + * @brief Gets the folder name. + * + * @remarks @a folder_name must be released with free() by you. + * + * @param[in] folder The handle to media folder + * @param[out] folder_name The name of the media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_folder_get_name(media_folder_h folder, char **folder_name); + +/** + * @brief Gets the modified date of the folder. + * + * @param[in] folder The handle to media folder + * @param[out] date The modified date of folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_folder_get_modified_time(media_folder_h folder, time_t *date); + +/** + * @brief Gets the folder storage type. + * + * @param[in] folder The handle to media folder + * @param[out] storage_type The storage type of the media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e *storage_type); + +/** + * @brief Gets the media folder from the media database. + * + * @details This function creates a new media folder handle from the media database by the given folder_id. + * media folder will be created, which is filled with folder information. + * + * @remarks @a folder must be released with media_folder_destroy() by you. + * + * @param[in] folder_id The ID of media folder + * @param[out] folder The media folder handle associated with the folder ID + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_folder_destroy() + * + */ +int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder); + +/** + * @brief Updates the media folder to the media database. + * + * @details The function updates the given media folder in the media database. The function should be called after any change in folder attributes, to be updated to the media + * database. For example, after using media_folder_set_name() for setting the name of the folder, media_folder_update_to_db() function should be called so as to update + * the given folder attibutes in the media database. + * + * @param[in] folder The handle to media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_folder_destroy() + * @see media_folder_set_name() + * + */ +int media_folder_update_to_db(media_folder_h folder); + +/** + * @brief Sets the folder name. + * + * @param[in] folder The handle to media folder + * @param[in] name The name of the media folder + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @post media_folder_update_to_db() + * + */ +int media_folder_set_name(media_folder_h folder, const char *name); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_FOLDER_H__ */ diff --git a/include/media_group.h b/include/media_group.h new file mode 100755 index 0000000..9159a85 --- /dev/null +++ b/include/media_group.h @@ -0,0 +1,312 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_GROUP_H__ +#define __TIZEN_MEDIA_GROUP_H__ + + +#include <media_content_type.h> + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_ALBUM_MODULE + * @{ + */ + +/** + * @brief Gets the number of album for the passed @a filter from the media database. + * + * @param[in] filter The handle to media filter. + * @param[out] album_count The count of media album + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_album_get_album_count_from_db(filter_h filter, int *album_count); + +/** + * @brief Iterates through the media album with optional @a filter from the media database. + * @details This function gets all media album handles meeting the given filter. + * The callback function will be invoked for every retrieved media album. + * If NULL is passed to the filter, no filtering is applied. + * + * @param [in] filter The handle to media filter + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_album_cb(). + * @see #media_album_cb + * @see media_content_connect() + * @see media_filter_create() + * + */ +int media_album_foreach_album_from_db(filter_h filter, media_album_cb callback, void *user_data); + +/** + * @brief Gets number of media info for the given album present in the media database. + * + * @param [in] album_id The ID of media album + * @param [in] filter The handle to media filter + * @param [out] media_count A count of album + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + */ +int media_album_get_media_count_from_db (int album_id, filter_h filter, int *media_count); + +/** + * @brief Iterates through the media files with optional @a filter in the given @a media @a album from the media database. + * @details This function gets all media files associated with the given media album and + * meeting desired filter option and calls registered callback function for + * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. + * + * @param [in] album_id The ID of media album + * @param [in] filter The handle to media filter + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_info_cb(). + * @see #media_info_cb + * @see media_content_connect() + * @see media_filter_create() + */ +int media_album_foreach_media_from_db(int album_id, filter_h filter, media_info_cb callback, void *user_data); + +/** + * @brief Destroys album handle. + * @details Function frees all resources related to album handle. This handle + * no longer can be used to perform any operation. A new handle has to + * be created before the next use. + * + * @param [in] album The handle to media album + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre Get copy of album handle by calling media_album_clone() + * @see media_album_clone() + */ +int media_album_destroy(media_album_h album); + +/** + * @brief Clones media album. + * @details This function copies the media album handle from a source to + * destination. There is no media_album_create() function. The media_album_h is created internally and available through + * media album foreach function such as media_album_foreach_album_from_db(). To use this handle outside of these foreach functions, + * use this function. + * + * @remark The destination handle must be released with media_album_destroy() by you. + * + * @param [in] src The source handle to media album + * @param [out] dst A destination handle to media album + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_album_destroy() + * @see media_album_foreach_album_from_db() + */ +int media_album_clone(media_album_h *dst, media_album_h src); + +/** + * @brief Gets a ID of the album. + * + * @param [in] album The handle to media album + * @param [out] album_id A ID of media album + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_album_foreach_album_from_db() + * + */ +int media_album_get_album_id(media_album_h album, int *album_id); + +/** + * @brief Gets a name of the album. + * + * @remarks @a album_name must be released with free() by you. + * + * @param [in] album The handle to media album + * @param [out] album_name A name of media album handle + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_album_get_name(media_album_h album, char **album_name); + +/** + * @brief Gets a name of the artist from album. + * + * @remarks @a artist must be released with free() by you. + * + * @param [in] album The handle to media album + * @param [out] artist A name of media artist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_album_get_artist(media_album_h album, char **artist); + +/** + * @brief Gets a album art path from album. + * + * @remarks @a album_art must be released with free() by you. + * + * @param [in] album The handle to media album + * @param [out] album_art A path of media album_art + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_album_get_album_art(media_album_h album, char **album_art); + +/** + * @brief Gets the media album from the media database. + * + * @details This function creates a new media album handle from the media database by the given album_id. + * media album will be created, which is filled with album information. + * + * @remarks @a folder must be released with media_album_destroy() by you. + * + * @param[in] album_id The ID of media album + * @param[out] album The album handle associated with the album ID + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_album_destroy() + * + */ +int media_album_get_album_from_db(int album_id, media_album_h *album); + + +/** + * @} + */ + + +/** +* @addtogroup CAPI_CONTENT_MEDIA_GROUP_MODULE +* @{ +*/ + + /** + * @brief Gets the number of group for the passed @a filter from the media database. + * + * @param[in] filter The handle to media filter + * @param [in] group The type of media group + * @param[out] group_count The count of media group + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count); + + /** + * @brief Iterates through the media group with optional @a filter from the media database. + * @details This function gets the names of media group meeting the given filter. + * The callback function will be invoked for every retrieved media group. + * If NULL is passed to the filter, no filtering is applied. + * + * @param [in] filter The handle to media filter + * @param [in] group The type of media group + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_group_cb(). + * @see #media_group_cb + * @see media_content_connect() + * @see media_filter_create() + */ +int media_group_foreach_group_from_db(filter_h filter, media_group_e group, media_group_cb callback, void *user_data); + + /** + * @brief Gets number of media info for the given media group present in the media database. + * + * @param [in] group_name The name of media group + * @param [in] group The type of media group + * @param [in] filter The handle to media filter + * @param [out] media_count The count of media + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + */ +int media_group_get_media_count_from_db(const char *group_name, media_group_e group, filter_h filter, int *media_count); + + /** + * @brief Iterates through the media files with optional @a filter in the given @a group from the media database. + * @details This function gets all media files associated with the given group and + * meeting desired filter option and calls registered callback function for + * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. + * + * @param [in] group_name The name of media group + * @param [in] group The type of media group + * @param [in] filter The handle to media filter + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_info_cb(). + * @see #media_info_cb + * @see media_content_connect() + * @see media_filter_create() + */ +int media_group_foreach_media_from_db(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data); + + /** + * @} + */ + +#ifdef __cplusplus + } +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_GROUP_H__ */ diff --git a/include/media_image.h b/include/media_image.h index ab9b16d..e6d7762 100644..100755 --- a/include/media_image.h +++ b/include/media_image.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -35,7 +35,7 @@ extern "C" { * @brief Clones image metadata. * @details Function copies the image metadata handle from source to destination. * - * @remark The destination handle must be released with image_meta_destroy() by you. + * @remark The destination handle must be released with image_meta_destroy() by you. * * @param [out] dst A destination handle to image metadata * @param [in] src The source handle to image metadata @@ -47,7 +47,6 @@ extern "C" { */ int image_meta_clone(image_meta_h *dst, image_meta_h src); - /** * @brief Destroys image metadata. * @details The function frees all resources related to the image metadata handle. This handle @@ -62,98 +61,90 @@ int image_meta_clone(image_meta_h *dst, image_meta_h src); */ int image_meta_destroy(image_meta_h image); - - /** - * @brief Gets the longitude from image metadata. - * @details Function gives geographic position: longitude value in degrees, - * which is positive for east and negative for west. + * @brief Gets the ID of image. * * @param [in] image The handle to image metadata - * @param [out] longitude The image longitude in degrees + * @param [out] media_id The ID of image * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int image_meta_get_longitude(image_meta_h image, double *longitude); - +int image_meta_get_media_id(image_meta_h image, char **media_id); /** - * @brief Gets the latitude from image metadata. - * @details Function gives geographic position: latitude value in degrees, - * which is positive for north and negative for south. + * @brief Gets image's width in pixels. * * @param [in] image The handle to image metadata - * @param [out] latitude The image latitude in degrees + * @param [out] width The image width in pixels * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int image_meta_get_latitude(image_meta_h image, double *latitude); - +int image_meta_get_width(image_meta_h image, int *width); /** - * @brief Gets the image description. - * - * @remarks @a description must be released with free() by you. + * @brief Gets image's height in pixels. * * @param [in] image The handle to image metadata - * @param [out] description The image description or NULL + * @param [out] height The image height in pixels * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int image_meta_get_description(image_meta_h image, char **description); - +int image_meta_get_height(image_meta_h image, int *height); /** - * @brief Gets image's width in pixels. + * @brief Gets the image orientation. * * @param [in] image The handle to image metadata - * @param [out] width The image width in pixels + * @param [out] orientation The image orientation * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int image_meta_get_width(image_meta_h image, int *width); - +int image_meta_get_orientation(image_meta_h image, media_content_orientation_e *orientation); /** - * @brief Gets image's height in pixels. + * @brief Gets the date, when image was created as time_t structure. * * @param [in] image The handle to image metadata - * @param [out] height The image height in pixels + * @param [out] date_taken The time, when image was taken (in seconds, since the Epoch) * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int image_meta_get_height(image_meta_h image, int *height); - +int image_meta_get_date_taken(image_meta_h image, char **date_taken); /** - * @brief Gets the image orientation. + * @brief Sets the image orientation. * * @param [in] image The handle to image metadata - * @param [out] orientation The image orientation + * @param [in] orientation The image orientation * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post image_meta_update_to_db() */ -int image_meta_get_orientation(image_meta_h image, media_content_orientation_e *orientation); - +int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation); /** - * @brief Gets the date, when image was created as time_t structure. + * @brief Updates the image to the media database. * - * @param [in] image The handle to image metadata - * @param [out] date_taken The time, when image was taken (in seconds, since the Epoch) + * @details The function updates the given image meta in the media database. The function should be called after any change in image attributes, to be updated to the media + * database. For example, after using image_meta_set_orientation() for setting the orientation of the image, image_meta_update_to_db() function should be called so as to update + * the given image attibutes in the media database. + * + * @param[in] image The handle to image * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see image_meta_set_orientation() + * */ -int image_meta_get_date_taken(image_meta_h image, time_t *date_taken); - +int image_meta_update_to_db(image_meta_h image); /** * @} diff --git a/include/media_info.h b/include/media_info.h index 7eb999e..7677352 100644..100755 --- a/include/media_info.h +++ b/include/media_info.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -33,12 +33,101 @@ extern "C" { */ /** + * @brief Inserts media file into the media database. + * @details This function inserts an media item into the content storage. + * Normally, inserting a media file in database is done automatically by media server, without calling this function. + * This function is only called when media server is busy and user needs to get quick result of inserting + * e.g. Taking a photo while media server is busy and user want to see the quick snapshot of the photo taken. + * @remark The handle must be released with media_info_destroy() by you. + * + * @param[in] path The path to the media file + * @param[out] info The handle to the media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @pre This function requires opened connection to content service by media_content_connect(). + * @see #media_content_type_e media_content_connect() + */ +int media_info_insert_to_db (const char *path, media_info_h *info); + +/** + * @brief Deletes media file from the media database. + * @details This function deletes an media item from the content storage. + * Normally, deleting a media file in database is done automatically by media server, without calling this function. + * This function is only called when media server is busy and user needs to get quick result of deleting + * + * @param[in] media_id The ID to the media file + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @pre This function requires opened connection to content service by media_content_connect(). + * @see #media_content_type_e media_content_connect() + */ +int media_info_delete_from_db(const char *media_id); + +/** + * @brief Destroys the media info. + * @details The function frees all resources related to the media info handle. This handle + * no longer can be used to perform any operation. New media info handle has to + * be created before next usage. + * + * @param[in] media The handle to media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre Get copy of media_info handle by calling media_info_clone() + * @see media_info_clone() + */ +int media_info_destroy(media_info_h media); + +/** + * @brief Clones the media info handle. + * + * @details This function copies the media info handle from a source to destination. + * There is no media_info_create() function. The media_info_h is created internally and + * available through media info foreach function such as media_info_foreach_media_from_db(). + * To use this handle outside of these foreach functions, use this function. + * @remark The destination handle must be released with media_info_destroy() by you. + * + * @param[out] dst A destination handle to media info + * @param[in] src The source handle to media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_info_destroy() + * @see audio_album_foreach_media_from_db() + * @see audio_playlist_foreach_media_from_db() + * @see audio_artist_foreach_media_from_db() + * @see audio_author_foreach_media_from_db() + * @see audio_genre_get_media_count_from_db() + * @see media_tag_foreach_media_from_db() + * @see media_info_foreach_media_from_db() + * @see media_folder_foreach_media_from_db() + * + */ +int media_info_clone(media_info_h *dst, media_info_h src); + +/** + * @brief Gets the number of media info for the passed @a filter from the media database. + * + * @param[in] filter The handle to filter. + * @param[out] media_count The count of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_info_get_media_count_from_db(filter_h filter, int *media_count); + +/** * @brief Iterates through media info from the media database. - * @details This function gets all media info handles meeting the given @a filter. The @a callback function will be invoked for every retrieved media info. - * If NULL is passed to the @a filter, no filtering is applied. + * @details This function gets all media info handles meeting the given @a filter. The @a callback function will be invoked for every retrieved media info. + * If NULL is passed to the @a filter, no filtering is applied. * @param[in] filter The handle to media info filter * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter @@ -46,78 +135,139 @@ extern "C" { * @pre This function requires opened connection to content service by media_content_connect(). * @post This function invokes media_info_cb(). * @see media_content_connect() - * @see #media_info_cb + * @see #media_info_cb * @see media_info_filter_create() * */ -int media_info_foreach_media_from_db(media_info_filter_h filter, media_info_cb callback, void *user_data); - +int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data); +/** + * @brief Gets the number of media tag for the passed @a filter in the given @a media ID from the media database. + * + * @param[in] media_id The ID of media info + * @param[in] filter The handle to media filter + * @param[out] tag_count The count of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count); /** - * @brief Iterates through the media tag in the given @a media @a info from the media database. + * @brief Iterates through the media tag in the given @a media @a info from the media database. * @details This function gets all media tag associated with the given @a media and calls registered callback function for every retrieved media tag. - * @param[in] media The handle to media info + * @param[in] media_id The ID of media info + * @param[in] filter The handle to media filter * @param[in] callback The callback function to invoke - * @param[in] user_data The user data to be passed to the callback function + * @param[in] user_data The user data to be passed to the callback function * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre This function requires opened connection to content service by media_content_connect(). * @post This function invokes media_tag_cb(). * @see media_content_connect() * @see #media_tag_cb */ -int media_info_foreach_tag_from_db(media_info_h media, media_tag_cb callback, void *user_data); +int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data); +/** + * @brief Gets the number of bookmark for the passed @a filter in the given @a media ID from the media database. + * + * @param[in] media_id The ID of media info + * @param[in] filter The handle to media filter + * @param[out] bookmark_count The count of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count); + +/** + * @brief Iterates through the media bookmark in the given @a media @a info from the media database. + * @details This function gets all media bookmark associated with the given @a media and calls registered callback function for every retrieved media bookmark. + * @param[in] media_id The ID of media info + * @param[in] filter The handle to media filter + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_bookmark_cb(). + * @see media_content_connect() + * @see #media_bookmark_cb + */ +int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data); +/** + * @brief Gets image metadata for a given media info. + * @details This function returns an image metadata handle retrieved from the media info. + * + * @remark The @a image handle must be released with image_meta_destroy() by you. + * + * @param [in] media The handle to media info + * @param[out] image A handle to image meta + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see image_meta_destroy() + */ +int media_info_get_image(media_info_h media, image_meta_h *image); /** - * @brief Clones the media info handle. + * @brief Gets video metadata for a given media info. + * @details This function returns a video metadata handle retrieved from the media info handle. * - * @details This function copies the media info handle from a source to destination. - * There is no media_info_create() function. The media_info_h is created internally and - * available through media info foreach function such as media_info_foreach_media_from_db(). - * To use this handle outside of these foreach functions, use this function. - * @remark The destination handle must be released with media_info_destroy() by you. + * @remark The @a video handle must be released with video_meta_destroy() by you. * - * @param[out] dst A destination handle to media info - * @param[in] src The source handle to media info + * @param [in] media The handle to media info + * @param[out] video A handle to the video meta * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory - * @see media_info_destroy() - * @see audio_album_foreach_media_from_db() - * @see audio_playlist_foreach_media_from_db() - * @see audio_artist_foreach_media_from_db() - * @see audio_author_foreach_media_from_db() - * @see audio_genre_get_media_count_from_db() - * @see media_tag_foreach_media_from_db() - * @see media_info_foreach_media_from_db() - * @see media_folder_foreach_media_from_db() + * @see video_meta_destroy() * */ -int media_info_clone(media_info_h* dst, media_info_h src); - +int media_info_get_video(media_info_h media, video_meta_h *video); /** - * @brief Destroys the media info. - * @details The function frees all resources related to the media info handle. This handle - * no longer can be used to perform any operation. New media info handle has to - * be created before next usage. + * @brief Gets audio metadata for a given media info. + * @details This function returns an audio metadata handle retrieved from the media info handle. * - * @param[in] media The handle to media info + * @remark The @a audio handle must be released with audio_meta_destroy() by you. + * + * @param [in] media The handle to media info + * @param[out] audio A handle to the audio meta * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of media_info handle by calling media_info_clone() - * @see media_info_clone() + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see audio_meta_destroy() */ -int media_info_destroy(media_info_h media); - +int media_info_get_audio(media_info_h media, audio_meta_h *audio); +/** + * @brief Gets ID to media info. + * + * + * @param [in] media_id The ID if media info + * @param [out] media_id The ID of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_info_get_media_id(media_info_h media, char **media_id); /** * @brief Gets path to media info. @@ -143,13 +293,76 @@ int media_info_get_file_path(media_info_h media, char **path); * @param[out] name The name of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ int media_info_get_display_name(media_info_h media, char **name); /** + * @brief Gets media info's content type. + * + * @param[in] media The handle to media info + * @param[out] type The type of media content(#media_content_type_e) + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_media_type(media_info_h media, media_content_type_e *type); + +/** + * @brief Gets name to media info. + * + * @remarks @a mime_type must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] mime_type The mime type of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_mime_type(media_info_h media, char **mime_type); + +/** + * @brief Gets media file's size. + * + * @param[in] media The handle to media info + * @param[out] size The type of media content + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_size(media_info_h media, unsigned long long *size); + +/** + * @brief Gets added time. + * + * @param[in] media The handle to media info + * @param[out] added_time The added time + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_added_time(media_info_h media, time_t *added_time); + +/** + * @brief Gets media info's date of modification. + * + * @param[in] media The handle to media info + * @param[out] time The date of modification + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_modified_time(media_info_h media, time_t *time); + +/** * @brief Gets the thumbnail to media info. * * @remarks @a path must be released with free() by you. @@ -158,140 +371,503 @@ int media_info_get_display_name(media_info_h media, char **name); * @param[out] path The path to thumbnail of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ int media_info_get_thumbnail_path(media_info_h media, char **path); /** - * @brief Gets media info's date of modification. + * @brief Gets the description to media info. + * + * @remarks @a description must be released with free() by you. * * @param[in] media The handle to media info - * @param[out] time The date of modification + * @param[out] description The description of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ -int media_info_get_date_modified(media_info_h media, time_t *time); +int media_info_get_description(media_info_h media, char **description); /** - * @brief Gets media info's content type. + * @brief Gets media info's longitude. * * @param[in] media The handle to media info - * @param[out] type The type of media content(#media_content_type_e). \n + * @param[out] longitude The longitude of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ -int media_info_get_media_type(media_info_h media, int *type); +int media_info_get_longitude(media_info_h media, double* longitude); +/** + * @brief Gets media info's latitude. + * + * @param[in] media The handle to media info + * @param[out] latitude The latitude of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_latitude(media_info_h media, double* latitude); +/** + * @brief Gets media info's altitude of modification. + * + * @param[in] media The handle to media info + * @param[out] altitude The altitude of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_altitude(media_info_h media, double* altitude); /** - * @brief Gets image metadata for a given media info from the media database. - * @details This function returns an image metadata handle retrieved from the media info. + * @brief Gets media info's rating. + * + * @param[in] media The handle to media info + * @param[out] rating The rating of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_rating(media_info_h media, int *rating); + +/** + * @brief Gets the given media info's favorite status. * - * @remark The @a image handle must be released with image_meta_destroy() by you. + * @param [in] media The handle to media info + * @param [out] favorite The media favorite status(non zero if favorite, 0 if not favorite) + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_favorite(media_info_h media, bool* favorite); + +/** + * @brief Gets the author to media info. + * + * @remarks @a author must be released with free() by you. * * @param[in] media The handle to media info - * @param[out] image A handle to image meta + * @param[out] author The author of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see image_meta_destroy() + * */ -int media_info_get_image_from_db(media_info_h media, image_meta_h* image); +int media_info_get_author(media_info_h media, char **author); /** - * @brief Gets video metadata for a given media info from the media database. - * @details This function returns a video metadata handle retrieved from the media info handle. + * @brief Gets the provider to media info. * - * @remark The @a video handle must be released with video_meta_destroy() by you. + * @remarks @a provider must be released with free() by you. * * @param[in] media The handle to media info - * @param[out] video A handle to the video meta + * @param[out] provider The provider of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_provider(media_info_h media, char **provider); + +/** + * @brief Gets the content name to media info. + * + * @remarks @a content_name must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] content_name The content name of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see video_meta_destroy() + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ -int media_info_get_video_from_db(media_info_h media, video_meta_h* video); +int media_info_get_content_name(media_info_h media, char **content_name); /** - * @brief Gets audio metadata for a given media info from the media database. - * @details This function returns an audio metadata handle retrieved from the media info handle. + * @brief Gets the provider to media info. * - * @remark The @a audio handle must be released with audio_meta_destroy() by you. + * @remarks @a category must be released with free() by you. * * @param[in] media The handle to media info - * @param[out] audio A handle to the audio meta + * @param[out] category The category of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_category(media_info_h media, char **category); + +/** + * @brief Gets the location_tag to media info. + * + * @remarks @a location_tag must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] location_tag The location of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see audio_meta_destroy() + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * */ -int media_info_get_audio_from_db(media_info_h media, audio_meta_h* audio); +int media_info_get_location_tag(media_info_h media, char **location_tag); +/** + * @brief Gets the age_rating to media info. + * + * @remarks @a age_rating must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] age_rating The age rating of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_age_rating(media_info_h media, char **age_rating); /** - * @brief Gets the given media info's favorite status. + * @brief Gets the keyword to media info. * - * @param [in] media The handle to media info - * @param [out] favorite The media favorite status(non zero if favorite, 0 if not favorite) + * @remarks @a keyword must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] keyword The keyword of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * */ -int media_info_get_favorite(media_info_h media, int* favorite); +int media_info_get_keyword(media_info_h media, char **keyword); +/** + * @brief Checks whether the media is protected via drm. + * + * @param[in] media The handle to media info + * @param[out] is_drm /@a true if the drm media, + * /@a false if not drm. + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_is_drm(media_info_h media, bool *is_drm); /** - * @brief Updates media info's favorite status to the media database. + * @brief Gets media info's storage_type. * - * @param [in] media The handle to media info - * @param [in] favorite The media favorite status(non zero if favorite, 0 if not favorite) + * @param[in] media The handle to media info + * @param[out] storage_type The storage type of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type); + +/** + * @brief Gets the media info from the media database. + * + * @details This function creates a new media handle from the media database by the given media_id. + * media info will be created, which is filled with info information. + * + * @remarks @a media must be released with media_tag_destroy() by you. + * + * @param[in] media_id The ID of media info + * @param[out] media The media handle associated with the media ID * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre This function requires opened connection to content service by media_content_connect(). * @see media_content_connect() - * @see media_info_meta_get_favorite() + * @see media_info_destroy() + * */ -int media_info_update_favorite_to_db(media_info_h media, int favorite); +int media_info_get_media_from_db(const char *media_id, media_info_h *media); +/** + * @brief Sets display name to media info. + * + * @param[in] media The handle to media info + * @param[in] display_name The display name of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_display_name(media_info_h media, const char *display_name); +/** + * @brief Sets description to media info. + * + * @param[in] media The handle to media info + * @param[in] description The description of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_description(media_info_h media, const char *description); /** - * @brief Inserts media file into the media database. - * @details This function inserts an media item with desired @a type into the content storage. - * Normally, inserting a media file in database is done automatically by media server, without calling this function. - * This function is only called when media server is busy and user needs to get quick result of inserting - * e.g. Taking a photo while media server is busy and user want to see the quick snapshot of the photo taken. + * @brief Sets longitude to media info. * - * @param[in] type The type of media content - * @param[in] path The path to the media file + * @param[in] media The handle to media info + * @param[in] longitude The longitude of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_longitude(media_info_h media, double longitude); + +/** + * @brief Sets latitude to media info. + * + * @param[in] media The handle to media info + * @param[in] latitude The latitude of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_latitude(media_info_h media, double latitude); + +/** + * @brief Sets altitude to media info. + * + * @param[in] media The handle to media info + * @param[in] altitude The altitude of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_altitude(media_info_h media, double altitude); + +/** + * @brief Sets rating to media info. + * + * @param[in] media The handle to media info + * @param[in] rating The rating of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_rating(media_info_h media, int rating); + +/** + * @brief Sets favorite to media info. + * + * @param[in] media The handle to media info + * @param[in] favorite The favorite of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_set_favorite(media_info_h media, bool favorite); + +/** + * @brief Sets author to media info. + * + * @param[in] media The handle to media info + * @param[in] author The author of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_set_author(media_info_h media, const char *author); + +/** + * @brief Sets provider to media info. + * + * @param[in] media The handle to media info + * @param[in] provider The provider of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + + * + */ +int media_info_set_provider(media_info_h media, const char *provider); + +/** + * @brief Sets content name to media info. + * + * @param[in] media The handle to media info + * @param[in] content_name The content name of media info * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_content_name(media_info_h media, const char *content_name); + +/** + * @brief Sets category to media info. + * + * @param[in] media The handle to media info + * @param[in] category The category of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_category(media_info_h media, const char *category); + +/** + * @brief Sets location tag to media info. + * + * @param[in] media The handle to media info + * @param[in] location_tag The location of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_location_tag(media_info_h media, const char *location_tag); + +/** + * @brief Sets age rating to media info. + * + * @param[in] media The handle to media info + * @param[in] age_rating The age rating of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_age_rating(media_info_h media, const char *age_rating); + +/** + * @brief Sets keyword to media info. + * + * @param[in] media The handle to media info + * @param[in] keyword The keyword of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_keyword(media_info_h media, const char *keyword); + +/** + * @brief Updates the media info to the media database. + * + * @details The function updates the given media info in the media database. The function should be called after any change in media, to be updated to the media + * database. For example, after using media_info_set_display_name() for setting the name of the media, media_info_update_to_db() function should be called so as to update + * the given media info attibutes in the media database. + * + * @param[in] media The handle to media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre This function requires opened connection to content service by media_content_connect(). - * @see #media_content_type_e media_content_connect() + * @see media_content_connect() + * @see media_info_set_display_name() + * @see media_info_set_description() + * @see media_info_set_longitude() + * @see media_info_set_latitude() + * @see media_info_set_altitude() + * @see media_info_set_rating() + * @see media_info_set_favorite() + * @see media_info_set_author() + * @see media_info_set_provider() + * @see media_info_set_content_name() + * @see media_info_set_category() + * @see media_info_set_location_tag() + * @see media_info_set_age_rating() + * */ -int media_info_insert_to_db(media_content_type_e type, const char *path); +int media_info_update_to_db(media_info_h media); +/** + * @brief Refresh the metadata of media to media database. + * + * @param[in] media_id The ID of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_info_refresh_metadata_to_db(const char *media_id); +/** + * @brief Sets added_time to media info. + * + * @param[in] media The handle to media info + * @param[in] added_time The added time of media info + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post media_info_update_to_db() + * + */ +int media_info_set_added_time(media_info_h media, time_t added_time); +/** + * @brief Moves the media info to the given destination path in the media database. + * + * @param[in] media The handle to media info + * @param[in] dst_path The path of destination + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_info_move_media_to_db(media_info_h media, const char* dst_path); /** * @} @@ -303,4 +879,3 @@ int media_info_insert_to_db(media_content_type_e type, const char *path); #endif /* __cplusplus */ #endif /* __TIZEN_MEDIA_INFORMATION_H__ */ - diff --git a/include/media_info_private.h b/include/media_info_private.h index 2c8c73a..526f7bf 100644..100755 --- a/include/media_info_private.h +++ b/include/media_info_private.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -19,20 +19,32 @@ #define __TIZEN_MEDIA_INFO_PRIVATE_H__ -#include <media_content_type.h> #include <string.h> #include <sqlite3.h> #include <stdlib.h> #include <stdio.h> +#include <glib.h> #include <media-svc.h> - +#include <media_content_type.h> +#include <dlog.h> #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_MEDIACONTENT" + +#define SAFE_STRLCAT(dst, src, n) g_strlcat(dst, src, n); +#define SAFE_FREE(src) {if(src) {free(src); src = NULL;}} +#define STRING_VALID(str) ((str != NULL && strlen(str) > 0) ? TRUE : FALSE) +#define SQLITE3_FINALIZE(x) {if(x != NULL) {sqlite3_finalize(x);}} #define MEDIA_CONTENT_TYPE 5 +#define MEDIA_REGISTER_TYPE 6 #define MEDIA_CONTENT_PATH_PHONE "/opt/media" /**< File path prefix of files stored in phone */ #define MEDIA_CONTENT_PATH_MMC "/mnt/mmc" /**< File path prefix of files stored in mmc card */ @@ -41,281 +53,679 @@ extern "C" { #define MIN_QUERY_SIZE 256 #define DEFAULT_QUERY_SIZE 1024 #define MAX_KEYWORD_SIZE 2048 - - - -typedef struct +#define COLLATE_STR_SIZE 32 +#define MEDIA_CONTENT_UUID_SIZE 36 + +typedef enum { + Table_Media, + Table_Folder, + Table_Bookmark, + Table_Tag, + Table_TagMap, +} media_info_table_e; + +typedef enum { + MEDIA_TAG_ADD, + MEDIA_TAG_REMOVE, + MEDIA_TAG_UPDATE_TAG_NAME, +} tag_function_e; + +typedef enum { + MEDIA_PLAYLIST_ADD, + MEDIA_PLAYLIST_REMOVE, + MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME, + MEDIA_PLAYLIST_UPDATE_PLAY_ORDER, +} playlist_function_e; + +typedef enum { + MEDIA_GROUP_NONE, + MEDIA_GROUP_ALBUM, + MEDIA_GROUP_ARTIST, + MEDIA_GROUP_GENRE, + MEDIA_GROUP_COMPOSER, + MEDIA_GROUP_YEAR, + MEDIA_GROUP_FOLDER, + MEDIA_GROUP_PLAYLIST, + MEDIA_GROUP_TAG, + MEDIA_GROUP_BOOKMARK, + MEDIA_GROUP_TAG_BY_MEDIA_ID, + MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, +} group_list_e; + +typedef struct _filter_s { - media_content_type_e media_type; // image, audio, video, all - int offset; // position of start - int count; // offset - media_info_search_type_e search_type; - char* keyword; // search condition like a sql "like" - media_content_order_e order; //The sort order - -}media_info_filter_s; - + char *condition; + char *order_keyword; + media_content_order_e order_type; + media_content_collation_e condition_collate_type; + media_content_collation_e order_collate_type; + int offset; + int count; +}filter_s; typedef struct { - int offset; // position of start - int count; // offset - media_folder_search_type_e search_type; - char* keyword; // search condition like a sql "like" - media_content_order_e order; //The sort order - -}media_folder_filter_s; - - -typedef struct -{ - int offset; // position of start - int count; // offset - media_tag_search_type_e search_type; - char* keyword; // search condition like a sql "like" - media_content_order_e order; //The sort order - -}media_tag_filter_s; - + char *folder_id; //image id, audio id, video id + char *path; + char *name; + time_t modified_time; + media_content_storage_e storage_type; +}media_folder_s; typedef struct { - int offset; // position of start - int count; // offset - media_audio_search_type_e search_type; - char* keyword; // search condition like a sql "like" - media_content_order_e order; //The sort order - -}media_audio_filter_s; + int tag_id; + char *name; +}media_tag_s; typedef struct { - int offset; // position of start - int count; // offset - media_content_order_e order; //The sort order - -}video_bookmark_filter_s; - + int bookmark_id; + char *media_id; + time_t marked_time; + char *thumbnail; +}media_bookmark_s; typedef struct { - char* folder_uid; //image id , audio id, video id - char* path; - char* name; - time_t date_modified; - media_content_storage_e storage_type; -}media_folder_s; + int album_id; + char *name; + char *artist; + char *album_art_path; +}media_album_s; typedef struct { - char* item_id; //image id , audio id, video id - char* file_path; - char* display_name; - char* thumbnail; - time_t date_modified; - int favorite; - media_content_type_e media_type; -}media_info_s; - + int playlist_id; //playlist id + char *name; // playlist name +}media_playlist_s; typedef struct { - int tag_id; - //int content_id; //replace to glist of item_h - char* name; - -}media_tag_s; - - -typedef struct -{ - char* image_id; - int longitude; - int latitude; - char* thumbnail; - char* description; + char *media_id; int width; int height; - int favorite; + char *date_taken; media_content_orientation_e orientation; - time_t date_taken; }image_meta_s; - -typedef struct +typedef struct { - char* video_id; - int longitude; - int latitude; - char* album; - char* artist; - char* title; - char* description; - char* thumbnail; - int time_played; + char *media_id; + char *title; + char *album; + char *artist; + char *genre; + char *composer; + char *year; + char *recorded_date; + char *copyright; + char *track_num; + int bitrate; int duration; int width; int height; - int favorite; - media_content_orientation_e orientation; - time_t date_taken; + int played_count; + time_t played_time; + int played_position; }video_meta_s; - -typedef struct -{ - int bookmark_id; - char* video_id; - time_t time_marked; - char* thumbnail; - -}video_bookmark_s; - - -typedef struct +typedef struct { - char* audio_id; - char* genre; - char* author; - char* album; - char* artist; - char* year; - char* copyright; - char* description; - char* format; + char *media_id; + char *title; + char *album; + char *artist; + char *genre; + char *composer; + char *year; + char *recorded_date; + char *copyright; + char *track_num; int bitrate; - int track_num; + int samplerate; + int channel; int duration; - int rating; - int count_played; - int time_played; - time_t time_added; - int size; - int category; - + int played_count; + time_t played_time; + int played_position; }audio_meta_s; typedef struct { - int playlist_id; //playlist id - char* name; // playlist name - -}audio_playlist_s; + char *media_id; //image id, audio id, video id + char *file_path; + char *display_name; + media_content_type_e media_type; + char *mime_type; + unsigned long long size; + time_t added_time; + time_t modified_time; + char *thumbnail; + char *description; + double longitude; + double latitude; + double altitude; + int rating; + int favourite; + char *author; + char *provider; + char *content_name; + char *category; + char *location_tag; + char *age_rating; + char *keyword; + int is_drm; + int storage_type; + image_meta_s *image_meta; + video_meta_s *video_meta; + audio_meta_s *audio_meta; +}media_info_s; +typedef struct +{ + char *name; +}media_artist_s; typedef struct { - char* name; -}audio_artist_s; + char *name; +}media_genre_s; typedef struct { - char* name; -}audio_genre_s; + char *name; +}media_composer_s; +typedef struct +{ + char *name; +}media_year_s; typedef struct { - char* name; -}audio_author_s; + char *media_id; // media_uuid + int function; // Add, remove, modify + char *tag_name; // tag_name +}media_tag_item_s; typedef struct { - char* name; -}audio_album_s; + char *media_id; // media_uuid + int function; // Add, remove, modify + char *playlist_name; // playlist_name + int playlist_member_id; // playlist unique id of media. Same content which has same media_id can be added to Playlist + int play_order; //play_order +}media_playlist_item_s; + +typedef struct _attribute_map_s +{ + GHashTable *attr_map; +}attribute_s; + +typedef struct attribute_s *attribute_h; + +/* DB Table */ +#define DB_TABLE_MEDIA "media" +#define DB_TABLE_FOLDER "folder" +#define DB_TABLE_ALBUM "album" +#define DB_TABLE_TAG "tag" +#define DB_TABLE_TAG_MAP "tag_map" +#define DB_TABLE_PLAYLIST "playlist" +#define DB_TABLE_PLAYLIST_MAP "playlist_map" +#define DB_TABLE_BOOKMARK "bookmark" + +/* DB View */ +#define DB_VIEW_PLAYLIST "playlist_view" +#define DB_VIEW_TAG "tag_view" + +/* DB Table Alias */ +#define DB_TABLE_ALIAS_MEDIA "m" +#define DB_TABLE_ALIAS_FOLDER "f" +#define DB_TABLE_ALIAS_PLAYLIST "p" +#define DB_TABLE_ALIAS_PLAYLIST_MAP "pm" +#define DB_TABLE_ALIAS_TAG "t" +#define DB_TABLE_ALIAS_BOOKMARK "b" +#define DB_TABLE_ALIAS_ALBUM "a" + +/* DB field for media */ +#define DB_FIELD_MEDIA_ID "media_uuid" +#define DB_FIELD_MEDIA_PATH "path" +#define DB_FIELD_MEDIA_DISPLAY_NAME "file_name" +#define DB_FIELD_MEDIA_TYPE "media_type" +#define DB_FIELD_MEDIA_MIME_TYPE "mime_type" +#define DB_FIELD_MEDIA_SIZE "size" +#define DB_FIELD_MEDIA_ADDED_TIME "added_time" +#define DB_FIELD_MEDIA_MODIFIED_TIME "modified_time" +#define DB_FIELD_MEDIA_THUMBNAIL_PATH "thumbnail_path" +#define DB_FIELD_MEDIA_TITLE "title" +#define DB_FIELD_MEDIA_ALBUM "album" +#define DB_FIELD_MEDIA_ARTIST "artist" +#define DB_FIELD_MEDIA_GENRE "genre" +#define DB_FIELD_MEDIA_COMPOSER "composer" +#define DB_FIELD_MEDIA_YEAR "year" +#define DB_FIELD_MEDIA_RECORDED_DATE "recorded_date" +#define DB_FIELD_MEDIA_COPYRIGHT "copyright" +#define DB_FIELD_MEDIA_TRACK_NUM "track_num" +#define DB_FIELD_MEDIA_DESCRIPTION "description" +#define DB_FIELD_MEDIA_BITRATE "bitrate" +#define DB_FIELD_MEDIA_SAMPLERATE "samplerate" +#define DB_FIELD_MEDIA_CHANNEL "channel" +#define DB_FIELD_MEDIA_DURATION "duration" +#define DB_FIELD_MEDIA_LONGITUDE "longitude" +#define DB_FIELD_MEDIA_LATITUDE "latitude" +#define DB_FIELD_MEDIA_ALTITUDE "altitude" +#define DB_FIELD_MEDIA_WIDTH "width" +#define DB_FIELD_MEDIA_HEIGHT "height" +#define DB_FIELD_MEDIA_DATETAKEN "datetaken" +#define DB_FIELD_MEDIA_ORIENTATION "orientation" +#define DB_FIELD_MEDIA_PLAYED_COUNT "played_count" +#define DB_FIELD_MEDIA_LAST_PLAYED_TIME "last_played_time" +#define DB_FIELD_MEDIA_LAST_PLAYED_POSITION "last_played_position" +#define DB_FIELD_MEDIA_RATING "rating" +#define DB_FIELD_MEDIA_FAVOURITE "favourite" +#define DB_FIELD_MEDIA_AUTHOR "author" +#define DB_FIELD_MEDIA_PROVIDER "provider" +#define DB_FIELD_MEDIA_CONTENT_NAME "content_name" +#define DB_FIELD_MEDIA_CATEGORY "category" +#define DB_FIELD_MEDIA_LOCATION_TAG "location_tag" +#define DB_FIELD_MEDIA_AGE_RATING "age_rating" +#define DB_FIELD_MEDIA_KEYWORD "keyword" +#define DB_FIELD_MEDIA_IS_DRM "is_drm" +#define DB_FIELD_MEDIA_STORAGE_TYPE "storage_type" + +/* DB field for folder */ +#define DB_FIELD_FOLDER_ID "folder_uuid" +#define DB_FIELD_FOLDER_PATH "path" +#define DB_FIELD_FOLDER_NAME "name" +#define DB_FIELD_FOLDER_MODIFIED_TIME "modified_time" +#define DB_FIELD_FOLDER_STORAGE_TYPE "storage_type" + +/* DB field for playlist */ +#define DB_FIELD_PLAYLIST_ID "playlist_id" +#define DB_FIELD_PLAYLIST_NAME "name" +#define DB_FIELD_PLAYLIST_MEMBER_ORDER "play_order" +#define DB_FIELD_PLAYLIST_MEDIA_COUNT "media_count" + +/* DB field for tag */ +#define DB_FIELD_TAG_ID "tag_id" +#define DB_FIELD_TAG_NAME "name" +#define DB_FIELD_TAG_MEDIA_COUNT "media_count" + +/* DB field for bookmark */ +#define DB_FIELD_BOOKMARK_ID "bookmark_id" +#define DB_FIELD_BOOKMARK_MARKED_TIME "marked_time" + +/* DB field for album*/ +#define DB_FIELD_ALBUM_ID "album_id" +#define DB_FIELD_ALBUM_NAME "name" +#define DB_FIELD_ALBUM_ARTIST "artist" + +/* DB Query Keyword */ +#define QUERY_KEYWORD_AND "AND" +#define QUERY_KEYWORD_OR "OR" +#define QUERY_KEYWORD_ORDER_BY "ORDER BY" +#define QUERY_KEYWORD_LIMIT "limit" +#define QUERY_KEYWORD_DESC "DESC" +#define QUERY_KEYWORD_SPACE " " +#define QUERY_KEYWORD_BRACKET ")" +#define UPDATE_SQL "UPDATE %s SET %s WHERE %s" + +/* DB TABLE JOIN */ +#define SELECT_EMPTY_PLAYLIST "SELECT playlist_id, name FROM "DB_TABLE_PLAYLIST" WHERE playlist_id NOT IN (select playlist_id from "DB_TABLE_PLAYLIST_MAP")" +#define SELECT_EMPTY_TAG "SELECT tag_id, name FROM "DB_TABLE_TAG" WHERE tag_id NOT IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP")" +#define FOLDER_MEDIA_JOIN "("DB_TABLE_FOLDER" AS f INNER JOIN "DB_TABLE_MEDIA" AS m ON f.folder_uuid=m.folder_uuid) WHERE m.validity=1" +#define PLAYLISTMAP_MEDIA_JOIN "("DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \ + ON (pm.media_uuid = m.media_uuid)) WHERE m.validity=1" +#define SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN "SELECT DISTINCT p.playlist_id, p.name FROM "DB_TABLE_PLAYLIST" AS p INNER JOIN "DB_TABLE_PLAYLIST_MAP" AS pm INNER JOIN "DB_TABLE_MEDIA" AS m \ + ON (p.playlist_id=pm.playlist_id AND pm.media_uuid = m.media_uuid) WHERE m.validity=1" +#define SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN "SELECT DISTINCT t.tag_id, t.name FROM "DB_TABLE_TAG" AS t INNER JOIN "DB_TABLE_MEDIA" AS m INNER JOIN "DB_TABLE_TAG_MAP" AS tm \ + ON (tm.media_uuid = m.media_uuid and tm.tag_id=t.tag_id) WHERE m.validity=1" +#define BOOKMARK_MEDIA_JOIN "("DB_TABLE_BOOKMARK" AS b INNER JOIN "DB_TABLE_MEDIA" AS m \ + ON (b.media_uuid = m.media_uuid)) WHERE m.validity=1" +#define ALBUM_MEDIA_JOIN "("DB_TABLE_ALBUM" AS a INNER JOIN "DB_TABLE_MEDIA" AS m \ + ON (a.album_id = m.album_id)) WHERE m.validity=1" + +/* Get Group List */ +#define SELECT_ALBUM_LIST "SELECT DISTINCT a.album_id, a.name, a.artist, a.album_art FROM "ALBUM_MEDIA_JOIN +#define SELECT_ARTIST_LIST "SELECT DISTINCT artist FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_GENRE_LIST "SELECT DISTINCT genre FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_COMPOSER_LIST "SELECT DISTINCT composer FROM "DB_TABLE_MEDIA" WHERE validity=1 " +#define SELECT_YEAR_LIST "SELECT DISTINCT year FROM "DB_TABLE_MEDIA" WHERE validity=1 " +#define SELECT_MEDIA_GROUP_LIST "SELECT DISTINCT %s FROM "DB_TABLE_MEDIA" WHERE validity=1 " + +#define SELECT_FOLDER_LIST "SELECT DISTINCT f.folder_uuid, f.path, f.name, f.storage_type, f.modified_time FROM "FOLDER_MEDIA_JOIN +//#define SELECT_TAG_LIST SELECT_EMPTY_TAG" UNION "SELECT_TAG_FROM_TAG_TAGMAP_MEDIA_JOIN +//#define SELECT_PLAYLIST_LIST SELECT_EMPTY_PLAYLIST" UNION "SELECT_PLAYLIST_FROM_PLAYLIST_PLAYLISTMAP_MEDIA_JOIN +#define SELECT_TAG_LIST "SELECT DISTINCT tag_id, name FROM "DB_VIEW_TAG" WHERE 1 " +#define SELECT_PLAYLIST_LIST "SELECT DISTINCT playlist_id, name FROM "DB_VIEW_PLAYLIST" WHERE 1 " +#define SELECT_BOOKMARK_LIST "SELECT DISTINCT b.bookmark_id, b.media_uuid, b.marked_time, b.thumbnail_path FROM "BOOKMARK_MEDIA_JOIN + +/* Get Group Count */ +#define SELECT_ALBUM_COUNT "SELECT COUNT(DISTINCT a.album_id) FROM "ALBUM_MEDIA_JOIN +#define SELECT_ARTIST_COUNT "SELECT COUNT(DISTINCT artist) FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_GENRE_COUNT "SELECT COUNT(DISTINCT genre) FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_COMPOSER_COUNT "SELECT COUNT(DISTINCT composer) FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_YEAR_COUNT "SELECT COUNT(DISTINCT year) FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_FOLDER_COUNT "SELECT COUNT(DISTINCT f.folder_uuid) FROM "FOLDER_MEDIA_JOIN +//#define SELECT_TAG_COUNT "SELECT COUNT(*) FROM ("SELECT_TAG_LIST +//#define SELECT_PLAYLIST_COUNT "SELECT COUNT(*) FROM ("SELECT_PLAYLIST_LIST +#define SELECT_TAG_COUNT "SELECT COUNT(DISTINCT tag_id) FROM "DB_VIEW_TAG" WHERE 1 " +#define SELECT_PLAYLIST_COUNT "SELECT COUNT(DISTINCT playlist_id) FROM "DB_VIEW_PLAYLIST" WHERE 1 " +#define SELECT_BOOKMARK_COUNT "SELECT COUNT(DISTINCT b.bookmark_id) FROM "BOOKMARK_MEDIA_JOIN +#define SELECT_MEDIA_GROUP_COUNT "SELECT COUNT(*) FROM ("SELECT_MEDIA_GROUP_LIST +/*count(distinct x) count only non-null values, but select distinct X returns include null. so sync the result of count and list, don't use count(distinct x)*/ + +/* Get Media Count of Group */ +#define SELECT_MEDIA_COUNT_FROM_MEDIA "SELECT COUNT(*) FROM ("SELECT_MEDIA_ITEM //to apply limit condition. "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_MEDIA_COUNT_FROM_ALBUM "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id='%d'" +#define SELECT_MEDIA_COUNT_FROM_ARTIST "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'" +#define SELECT_MEDIA_COUNT_FROM_GENRE "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'" +#define SELECT_MEDIA_COUNT_FROM_COMPOSER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND composer='%q'" +#define SELECT_MEDIA_COUNT_FROM_YEAR "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'" +#define SELECT_MEDIA_COUNT_FROM_GROUP "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP //to apply limit condition. +#define SELECT_MEDIA_COUNT_FROM_GROUP_NULL "SELECT COUNT(*) FROM ("SELECT_MEDIA_FROM_GROUP_NULL //to apply limit condition. +#define SELECT_MEDIA_COUNT_FROM_FOLDER "SELECT COUNT(*) FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'" +#define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid IN \ + (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND media_uuid IN \ + (SELECT media_uuid FROM "DB_TABLE_MEDIA" WHERE validity=1" +//#define SELECT_MEDIA_COUNT_FROM_TAG "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE (tag_id=%d AND media_count>0) " +//#define SELECT_MEDIA_COUNT_FROM_PLAYLIST "SELECT COUNT(*) FROM "DB_VIEW_PLAYLIST" WHERE (playlist_id=%d and media_count>0) " + +/* Get Group Info by Group ID*/ +#define SELECT_ALBUM_FROM_ALBUM "SELECT * FROM "DB_TABLE_ALBUM" WHERE album_id=%d" +#define SELECT_FOLDER_FROM_FOLDER "SELECT * FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%s'" +#define SELECT_FOLDER_BY_PATH "SELECT * FROM "DB_TABLE_FOLDER" WHERE path='%q'" +#define SELECT_PLAYLIST_FROM_PLAYLIST "SELECT * FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" +#define SELECT_TAG_FROM_TAG "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id=%d" +#define SELECT_TAG_BY_NAME "SELECT * FROM "DB_TABLE_TAG" WHERE name='%q'" + +/* Tag info*/ +#define INSERT_TAG_TO_TAG "INSERT INTO "DB_TABLE_TAG" (name) VALUES (%Q)" +#define REMOVE_TAG_ITEM_FROM_TAG_MAP "DELETE FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d AND media_uuid='%q'" +#define UPDATE_TAG_NAME_FROM_TAG "UPDATE "DB_TABLE_TAG" SET name='%q' WHERE tag_id=%d" +//#define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%q')" +//#define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_TAG" WHERE tag_id IN (SELECT tag_id FROM "DB_TABLE_TAG_MAP" WHERE media_uuid = '%s')" +#define SELECT_TAG_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_VIEW_TAG" WHERE media_uuid = '%q'" +#define SELECT_TAG_LIST_BY_MEDIA_ID "SELECT tag_id, name FROM "DB_VIEW_TAG" WHERE media_uuid = '%s'" + +/* Playlist Info */ +#define INSERT_PLAYLIST_TO_PLAYLIST "INSERT INTO "DB_TABLE_PLAYLIST" (name) VALUES (%Q)" +#define UPDATE_PLAYLIST_NAME_FROM_PLAYLIST "UPDATE "DB_TABLE_PLAYLIST" SET name='%q' WHERE playlist_id=%d" +#define SELECT_PLAYLIST_ID_FROM_PLAYLIST "SELECT playlist_id FROM "DB_TABLE_PLAYLIST" WHERE name='%q'" +//#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_MAP "SELECT pm._id, pm.media_uuid FROM "PLAYLISTMAP_MEDIA_JOIN" AND pm.playlist_id=%d" +#define SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW "SELECT pm_id, media_uuid FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d " + +//#define SELECT_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT play_order FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d and _id=%d" +#define SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT play_order FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d and pm_id=%d" +//#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_MAP "SELECT MAX(play_order) FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d" +#define SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW "SELECT MAX(play_order) FROM "DB_VIEW_PLAYLIST" WHERE playlist_id=%d" +#define REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP "DELETE FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d AND _id=%d" +#define UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP "UPDATE "DB_TABLE_PLAYLIST_MAP" SET play_order=%d WHERE playlist_id=%d AND _id=%d" + +/* Bookmark */ +#define INSERT_BOOKMARK_TO_BOOKMARK "INSERT INTO "DB_TABLE_BOOKMARK" (media_uuid, marked_time, thumbnail_path) VALUES ('%q', '%d', %Q)" +#define SELECT_BOOKMARK_COUNT_BY_MEDIA_ID "SELECT COUNT(*) FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'" +#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%q'" +#define SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL "SELECT * FROM "DB_TABLE_BOOKMARK" WHERE media_uuid='%s'" + +/* Get Meta */ +#define MEDIA_AV_META "media_uuid, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position" +#define MEDIA_IMAGE_META "media_uuid, width, height, datetaken, orientation" +#define SELECT_IMAGE_FROM_MEDIA "SELECT "MEDIA_IMAGE_META" FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'" +#define SELECT_AUDIO_FROM_MEDIA "SELECT "MEDIA_AV_META", samplerate, channel FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'" +#define SELECT_VIDEO_FROM_MEDIA "SELECT "MEDIA_AV_META", width, height FROM "DB_TABLE_MEDIA" WHERE media_uuid='%s'" + +/* Update Meta*/ +#define UPDATE_AV_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET played_count=%d, last_played_time=%d, last_played_position=%d WHERE media_uuid='%q'" +#define UPDATE_IMAGE_META_FROM_MEDIA "UPDATE "DB_TABLE_MEDIA" SET orientation=%d WHERE media_uuid='%q'" + +/* Get Media list of Group */ +//#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, +// rating, favourite, author, provider, content_name, category, location_tag, age_rating, is_drm, storage_type" +#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, \ + rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel" + +#define SELECT_MEDIA_ITEM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1" +#define SELECT_MEDIA_FROM_MEDIA "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND media_uuid='%s'" +#define SELECT_MEDIA_BY_PATH "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND path='%q'" +#define SELECT_MEDIA_FROM_ALBUM "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND album_id=%d" +#define SELECT_MEDIA_FROM_ARTIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND artist='%q'" +#define SELECT_MEDIA_FROM_GENRE "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND genre='%q'" +#define SELECT_MEDIA_FROM_COMPOSER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND author='%q'" +#define SELECT_MEDIA_FROM_YEAR "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND year='%q'" +#define SELECT_MEDIA_FROM_GROUP "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s='%q'" +#define SELECT_MEDIA_FROM_GROUP_NULL "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND %s IS NULL" +#define SELECT_MEDIA_FROM_FOLDER "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE validity=1 AND folder_uuid='%q'" +#define SELECT_MEDIA_FROM_TAG "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_TAG_MAP" WHERE tag_id=%d) AND validity=1" +#define SELECT_MEDIA_FROM_PLAYLIST "SELECT "MEDIA_INFO_ITEM" FROM "DB_TABLE_MEDIA" WHERE media_uuid IN (SELECT media_uuid FROM "DB_TABLE_PLAYLIST_MAP" WHERE playlist_id=%d) AND validity=1" + +/* Delete */ +#define DELETE_MEDIA_FROM_MEDIA "DELETE FROM "DB_TABLE_MEDIA" WHERE media_uuid='%q'" +#define DELETE_FOLDER_FROM_FOLDER "DELETE FROM "DB_TABLE_FOLDER" WHERE folder_uuid='%q'" +#define DELETE_PLAYLIST_FROM_PLAYLIST "DELETE FROM "DB_TABLE_PLAYLIST" WHERE playlist_id=%d" +#define DELETE_TAG_FROM_TAG "DELETE FROM "DB_TABLE_TAG" WHERE tag_id=%d" +#define DELETE_BOOKMARK_FROM_BOOKMARK "DELETE FROM "DB_TABLE_BOOKMARK" WHERE bookmark_id=%d" +/** + *@internal + */ +int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query); +/** + *@internal + */ +int _content_error_capi(int type, int cotent_error); +/** + *@internal + */ +int _content_get_storage_type(const char *full_path); -#define CONDITION_TYPE_IMAGE "content_type=1" -#define CONDITION_TYPE_VIDEO "content_type=2" -#define CONDITION_TYPE_AUDIO "content_type=3" -#define QUERY_KEYWORD_AND "and" -#define QUERY_KEYWORD_OR "or" -#define QUERY_KEYWORD_ORDER_BY "order by" -#define QUERY_KEYWORD_LIMIT "limit" -#define QUERY_KEYWORD_DESC "desc" -#define QUERY_KEYWORD_SPACE " " -#define DB_FIELD_FOLDER_UID "folder_uuid" -#define DB_FILED_DISPLAY_NAME "display_name" -#define DB_FILED_DATE_MODIFIED "date_modified" -#define DB_FILED_MODIFIED_DATE "modified_date" -#define DB_FILED_NAME "name" -#define DB_FIELD_THUMBNAIL_PATH "thumbnail_path" -#define DB_FIELD_MARKED_TIME "marked_time" -#define DB_FIELD_TAG_NAME "tag_name" -#define DB_FIELD_ID "_id" -#define DB_FIELD_ADDED_TIME "added_time" - -#define SELECT_MEDIA_ITEM "select item_id, file_path, display_name, thumbnail, date_modified,content_type, favourite from item_view where 1" -#define SELECT_ALL_FOLDER "select folder_uuid, path, name, storage_type,modified_date from (select folder_uuid, path, folder_name as name, storage_type,modified_date from visual_folder where valid=1 union select folder_uuid, path, folder_name as name, storage_type,modified_date from audio_folder) where 1" -#define SELECT_COUNT_ITEM "select count(*) from item_view where 1" -#define SELECT_TAG_LIST "select _id, tag_name from visual_tag where 1" -#define SELECT_MEDIA_FROM_TAG "SELECT t._id, tm.visual_uuid, m.display_name as display_name, modified_date 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, display_name, modified_date 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=0 " -#define SELECT_PLAYLIST "select _id,name from audio_playlists where 1" -#define SELECT_MEDIA_FROM_PLAYLIST "select item_id, file_path, display_name, thumbnail, date_modified,content_type, favourite from item_view where 1 and content_type=3 and item_id IN (select audio_uuid from audio_playlists_map where playlist_id=%d)" -#define SELECT_GENRE_LIST "select distinct genre as name from audio_media where valid=1" -#define SELECT_MEDIA_FROM_GENRE "select audio_uuid ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_uuid from audio_media where valid=1 and genre='%s'" -#define SELECT_MEDIA_COUNT_FROM_GENRE "select count(*) from audio_media where valid=1 and genre='%s'" -#define SELECT_ALBUM_LIST "select distinct album as name from audio_media where valid=1 " -#define SELECT_MEDIA_FROM_ALBUM "select audio_uuid ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_uuid from audio_media where valid=1 and album='%s'" -#define SELECT_MEDIA_COUNT_FROM_ALBUM "select count(*) from audio_media where valid=1 and album='%s'" -#define SELECT_AUTHOR_LIST "select distinct author as name from audio_media where valid=1 " -#define SELECT_MEDIA_FROM_AUTHOR "select audio_uuid ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_uuid from audio_media where valid=1 and author='%s'" -#define SELECT_MEDIA_COUNT_FROM_AUTHOR "select count(*) from audio_media where valid=1 and author='%s'" -#define SELECT_MEDIA_ARTIST_LIST "select distinct artist as name from audio_media where valid=1" -#define SELECT_MEDIA_FROM_ARTIST "select audio_uuid ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_uuid from audio_media where valid=1 and artist='%s'" -#define SELECT_MEDIA_COUNT_FROM_ARTIST "select count(*) from audio_media where valid=1 and artist='%s'" -#define SELECT_BOOKMARK_FROM_VIDEO "select _id,visual_uuid,marked_time,thumbnail_path from video_bookmark where visual_uuid='%s' " +/** + *@internal + */ +int _content_query_sql(char *query_str); +/** + *@internal + */ +MediaSvcHandle* _content_get_db_handle(void); /** *@internal */ -void _content_folder_get_detail(sqlite3_stmt *stmt, media_folder_h folder); +attribute_h _content_get_attirbute_handle(void); /** *@internal */ -int _content_query_prepare(sqlite3_stmt **stmt, char *select_query,char *condition_query, char *search_query, char *limit_query,char *order ); +attribute_h _content_get_alias_attirbute_handle(void); +/** + *@internal + */ +void _media_info_item_get_detail(sqlite3_stmt *stmt, media_info_h media); /** *@internal */ -void _content_item_get_detail(sqlite3_stmt *stmt, media_info_h item); +int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count); /** *@internal */ -int _content_error_capi(media_content_type_e type, int cotent_error); +int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count); /** *@internal */ -int _content_get_storage_type(const char* full_path); +int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data); /** *@internal */ -int _content_get_audio_category(const char* file_full_path,int* category); +int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data); /** *@internal */ -int _content_query_sql(char *query_str); +int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data); + +/** + *@internal + */ +int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data); + +/** + *@internal + */ +int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data); + +/** + *@internal + */ +int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data); + +/** + *@internal + */ +int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data); + +/** + *@internal + */ +int _media_db_get_group(filter_h filter, media_group_cb callback, void *user_data, group_list_e group_type); + +/** + *@internal + */ +int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count); + +/** + *@internal + */ +int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count); + +/** + *@internal + */ +int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type); + +/** + *@internal + */ +int _media_db_get_group_item(const char *group_name, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type); /** *@internal */ -MediaSvcHandle* _content_get_db_handle(); +int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count); +/** + *@internal + */ +int _media_db_get_media_group_item(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data); + +/** + * @brief Creates a media filter attribute handle. + * @details This function creates a media filter attribute handle. The handle can be + * used to convert to attributes of database from attributes of user. + * @remarks The @a handle must be released with media_filter_attribute_destory() by you. + * @param[out] filter A handle to media filter attribute + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_filter_attribute_destory() + * + */ +int _media_filter_attribute_create(attribute_h *attr); + +/** + * @brief Add the attributes to the handle. + * @details This function add the attribute to handle. + * @param[in] filter The handle to media filter attribute + * @param[in] user_attr The user attribute + * @param[in] platform_attr The platform attribute + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_filter_attribute_remove() + * + */ +int _media_filter_attribute_add(attribute_h atrr, char *user_attr, char *platform_attr); + +/** + * @brief Remove the attributes from the handle. + * @details This function remove the attribute from handle. + * @param[in] filter The handle to media filter attribute + * @param[in] user_attr The user attribute + * @param[in] platform_attr The platform attribute + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_filter_attribute_remove() + * + */ +int _media_filter_attribute_remove(attribute_h atrr, char *user_attr); + +/** + * @brief Destroys a media filter attribute handle. + * @details The function frees all resources related to the media filter attribute handle. The filter attribute + * handle no longer can be used to perform any operation. A new handle + * has to be created before the next usage. + * + * @param[in] filter The handle to media filter attribute + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_filter_create() + * + */ +int _media_filter_attribute_destory(attribute_h attr); + +/** + * @brief Replace to platform attributes from user attributes. + * @details This function replace to platform attributes from user attributes to generate the WHERE clause + * @param[in] filter The handle to media filter attribute + * @param[in] user_attr The user attribute + * @param[in] platform_attr The platform attribute + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_filter_attribute_create() + * @see media_filter_attribute_destory() + * + */ +int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition); +int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option); + +#define media_content_retv_if(expr, val) do { \ + if(expr) { \ + LOGE("[%s-%d]", __FUNCTION__, __LINE__); \ + return (val); \ + } \ + } while (0) + +#define media_content_debug(fmt, arg...) do { \ + LOGD("[%s-%d]"fmt"", __FUNCTION__, __LINE__,##arg); \ + } while (0) + +#define media_content_error(fmt, arg...) do { \ + LOGE("[%s-%d]"fmt"", __FUNCTION__, __LINE__,##arg); \ + } while (0) + +#define media_content_debug_func() do { \ + LOGD("[%s-%d]", __FUNCTION__, __LINE__); \ + } while (0) #ifdef __cplusplus } #endif /* __cplusplus */ #endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/ - - - diff --git a/include/media_playlist.h b/include/media_playlist.h new file mode 100755 index 0000000..5786395 --- /dev/null +++ b/include/media_playlist.h @@ -0,0 +1,327 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_PLAYLIST_H__ +#define __TIZEN_MEDIA_PLAYLIST_H__ + +#include <media_content_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_PLAYLIST_MODULE + * @{ + */ + +/** + * @brief Gets the number of playlist for the passed @a filter from the media database. + * + * @param[in] filter The handle to filter. + * @param[out] playlist_count The count of media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count); + +/** + * @brief Iterates through the media playlist with optional @a filter from the media database. + * @details This function gets all media playlist handles meeting the given filter. + * The callback function will be invoked for every retrieved media playlist. + * If NULL is passed to the filter, no filtering is applied. + * + * @param [in] filter The handle to audio filter + * @param [in] callback The callback function to invoke + * @param [in] user_data User data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_playlist_cb(). + * @see #media_playlist_cb + * @see media_content_connect() + * @see media_filter_create() + * + */ +int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data); + +/** + * @brief Gets number of media info for the given playlist present in the media database. + * + * @param [in] playlist_id The ID of media playlist + * @param [in] filter The handle to media filter + * @param [out] media_count The number of media items + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count); + +/** + * @brief Iterates through the media files with optional @a filter in the given @a audio @a playlist from the media database. + * @details This function gets all media files associated with the given media playlist and + * meeting desired filter option and calls registered callback function for + * every retrieved media info. If NULL is passed to the @a filter, no filtering is applied. + * + * @param [in] playlist_id The ID of media playlist + * @param [in] filter The handle to audio filter + * @param [in] callback The callback function to invoke + * @param [in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_info_cb(). + * @see #media_info_cb + * @see media_content_connect() + * @see media_filter_create() + * + */ +int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data); + +/** + * @brief Inserts a new playlist with given name in the media database. + * + * @remark The created handle must be released with media_playlist_destroy() by you. + * @param [in] name The name of the inserted playlist + * @param [out] playlist A created handle to media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_playlist_delete_from_db() + * + */ +int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist); + +/** + * @brief Deletes the given playlist from the media database. + * + * @param [in] playlist The handle to media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_playlist_insert_to_db() + * + */ +int media_playlist_delete_from_db(int playlist_id); + +/** + * @brief Gets the media playlist from the media database. + * + * @details This function creates a new media playlist handle from the media database by the given playlist_id. + * media playlist will be created, which is filled with playlist information. + * + * @remarks @a playlist must be released with media_playlist_destroy() by you. + * + * @param[in] playlist_id The ID of media playlist + * @param [in] filter The handle to audio filter + * @param[out] playlist The media playlist handle associated with the playlist ID + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_playlist_destroy() + * + */ +int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist); + +/** + * @brief Destroys a playlist handle. + * @details Function frees all resources related to playlist handle. This + * handle no longer can be used to perform any operation. New handle has to + * be created before next usage. + * + * @param [in] playlist The handle to media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_playlist_clone() + * @pre Get copy of playlist handle by calling media_playlist_clone() or media_playlist_insert_to_db() + * @see media_playlist_clone() + * + */ +int media_playlist_destroy(media_playlist_h playlist); + +/** + * @brief Clones playlist handle. + * @details This function copies the media playlist handle from a source to + * destination. There is no media_playlist_create() function. The media_playlist_h is created internally and available through + * media playlist foreach function such as media_playlist_foreach_playlist_from_db(). To use this handle outside of these foreach functions, + * use this function. + * + * @remark The destination handle must be released with media_playlist_destroy() by you. + * + * @param [in] src The source handle to media playlist + * @param [out] dst A destination handle to media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @see media_playlist_destroy() + * @see media_playlist_foreach_playlist_from_db() + */ +int media_playlist_clone(media_playlist_h *dst, media_playlist_h src); + +/** + * @brief Gets media playlist's ID. + * + * @param [in] playlist The handle to media playlist + * @param [out] playlist_id The ID of media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id); + +/** + * @brief Gets a name of the playlist. + * + * @remarks @a playlist_name must be released with free() by you. + * + * @param [in] playlist The handle to media playlist + * @param [out] playlist_name The playlist name + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_playlist_get_name(media_playlist_h playlist, char **playlist_name); + +/** + * @brief Sets the playlist name. + * + * @param[in] playlist The handle to media playlist + * @param[in] playlist_name The name of the media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @post media_playlist_update_to_db() + * + */ +int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name); + +/** + * @brief Sets the played order in the playlist. + * + * @param[in] playlist The handle to media playlist + * @param[in] playlist_member_id The ID to member of playlist + * @param[in] play_order The played order + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @post media_playlist_update_to_db() + * + */ +int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order); + +/** + * @brief Adds a new media info to the playlist. + * + * @param[in] playlist The handle to media playlist + * @param[in] media_id The ID to media info which is added + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post media_playlist_update_to_db() + * @see media_content_connect() + * @see media_playlist_remove_media() + * + */ +int media_playlist_add_media(media_playlist_h playlist, const char *media_id); + +/** + * @brief Removes the playlist member related with media from the given playlist. + * + * @param[in] playlist The handle to media playlist + * @param[in] playlist_member_id The ID to member of playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post media_playlist_update_to_db() + * @see media_content_connect() + * @see media_playlist_add_media() + * + */ +int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id); + +/** + * @brief Gets the played order in the playlist. + * + * @param[in] playlist The handle to media playlist + * @param[in] playlist_member_id The ID to member of playlist + * @param [out] play_order The played order + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order); + +/** + * @brief Updates the media playlist to the media database. + * + * @details The function updates the given media playlist in the media database. The function should be called after any change in playlist, to be updated to the media + * database. For example, after using media_playlist_set_name() for setting the name of the playlist, media_playlist_update_to_db() function should be called so as to update + * the given playlist attibutes in the media database. + * + * @param[in] playlist The handle to media playlist + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_playlist_destroy() + * @see media_playlist_add_media() + * @see media_playlist_remove_media() + * @see media_playlist_set_name() + * @see media_playlist_set_play_order() + * + */ +int media_playlist_update_to_db(media_playlist_h playlist); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*__TIZEN_MEDIA_PLAYLIST_H__*/ diff --git a/include/media_tag.h b/include/media_tag.h index e334119..2d0eee8 100755 --- a/include/media_tag.h +++ b/include/media_tag.h @@ -1,228 +1,300 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 __TIZEN_MEDIA_TAG_H__
-#define __TIZEN_MEDIA_TAG_H__
-
-#include <media_content_type.h>
-
-#ifdef __cplusplus
-extern "C" {
-#endif /* __cplusplus */
-
-
-/**
- * @addtogroup CAPI_CONTENT_MEDIA_TAG_MODULE
- * @{
- */
-
-/**
- * @brief Iterates through tags from the media database.
- * @details This function gets all tags meeting a desired @a filter
- * and calls a registered callback function for every retrieved tag. If NULL is passed to the @a filter, no filtering is applied.
- *
- * @param[in] filter The handle to tag filter
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre This function requires opened connection to content service by media_content_connect().
- * @post This function invokes media_tag_cb().
- * @see media_content_connect()
- * @see #media_tag_cb
- * @see media_tag_filter_create()
- *
- */
-
-
-int media_tag_foreach_tag_from_db(media_tag_filter_h filter, media_tag_cb callback, void *user_data);
-
-
-/**
- * @brief Iterates through media items for a given tag from the media database.
- * @details This function gets all media items associated with a given tag and
- * meeting a desired @a filter and calls a registered callback function for
- * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied.
- *
- * @param[in] tag The handle to media tag
- * @param[in] filter The handle to media info filter
- * @param[in] callback The callback function to invoke
- * @param[in] user_data The user data to be passed to the callback function
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @pre This function requires opened connection to content service by media_content_connect().
- * @post This function invokes media_info_cb().
- * @see media_content_connect()
- * @see #media_info_cb
- * @see media_info_filter_create()
- */
-int media_tag_foreach_media_from_db(media_tag_h tag, media_info_filter_h filter, media_info_cb callback, void *user_data);
-
-/**
- * @brief Inserts a new tag in the media database.
- *
- * @remark The created tag handle must be released with media_tag_destroy() by you.
- *
- * @param[in] tag_name The tag name to be inserted
- * @param[out] tag A created handle to media tag
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- * @see media_tag_delete_from_db()
- * @see media_tag_destroy()
- *
- */
- int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag);
-
-/**
- * @brief Deletes a given tag from the media database.
- *
- * @param[in] tag The handle to media tag
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO Only video and image info can be added to Tag
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- * @see media_tag_insert_to_db()
- *
- */
- int media_tag_delete_from_db(media_tag_h tag);
-
-
-/**
- * @brief Adds a new media info to the tag to media database.
- *
- * @param[in] tag The handle to media tag
- * @param[in] media The handle to media info which is added
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO Only video and image info can be added to Tag
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- * @see media_tag_remove_media_from_db()
- *
- */
-int media_tag_add_media_to_db(media_tag_h tag, media_info_h media);
-
-/**
- * @brief Removes the media info from the given tag in the media database.
- * @param[in] tag The handle to media tag
- * @param[in] media The media info handle which should be removed
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO Only video and image info can be supported to Tag
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- * @see media_tag_add_media_to_db()
- *
- */
-int media_tag_remove_media_from_db(media_tag_h tag, media_info_h media);
-
-
-/**
- * @brief Clones the media tag.
- * @details This function copies the media tag handle from a source to destination.
- * There is no media_tag_create() function. The media_tag_h is created internally and available through media tag foreach function
- * such as media_tag_foreach_tag_from_db().
- * To use this handle outside of these foreach functions, use this function.
- * @remark The destination handle must be released with media_tag_destroy() by you.
- *
- * @param[out] dst A destination handle to media tag
- * @param[in] src The source handle to media tag
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @see media_tag_destroy()
- *
- */
-int media_tag_clone(media_tag_h *dst, media_tag_h src);
-
-
-
-/**
- * @brief Destroys the media tag.
- * @details This function frees all resources related to the tag handle. The tag handle can no longer
- * be used for any operation. A new tag handle has to be created before next usage.
- *
- * @param[in] tag The media tag handle
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre A copy of the media tag handle created by calling media_tag_clone() or media_tag_insert_to_db()
- * @see media_tag_clone()
- * @see media_tag_insert_to_db()
- *
- */
-int media_tag_destroy(media_tag_h tag);
-
-
-/**
- * @brief Gets the tag name.
- *
- * @remarks @a tag_name must be released with free() by you.
- *
- * @param[in] tag The handle to media tag
- * @param[out] tag_name The name of the tag
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- *
- */
-int media_tag_get_name(media_tag_h tag, char **tag_name);
-
-/**
- * @brief Updates the tag name.
- * @details This function updates the tag name in media database.
- *
- *
- * @param[in] tag The handle to media tag
- * @param[in] tag_name The new name for the tag
- * @return 0 on success, otherwise a negative error value.
- * @retval #MEDIA_CONTENT_ERROR_NONE Successful
- * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory
- * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter
- * @pre This function requires opened connection to content service by media_content_connect().
- * @see media_content_connect()
- */
-int media_tag_update_name_to_db(media_tag_h tag, const char *tag_name);
-
-
-/**
- * @}
- */
-
-#ifdef __cplusplus
-}
-#endif /* __cplusplus */
-
-#endif /* __TIZEN_MEDIA_TAG_H__ */
-
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_TAG_H__ +#define __TIZEN_MEDIA_TAG_H__ + +#include <media_content_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_TAG_MODULE + * @{ + */ + +/** + * @brief Inserts a new tag in the media database. + * + * @remark The created tag handle must be released with media_tag_destroy() by you. + * + * @param[in] tag_name The tag name to be inserted + * @param[out] tag A created handle to media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_tag_delete_from_db() + * @see media_tag_destroy() + * + */ +int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag); + +/** + * @brief Deletes a given tag from the media database. + * + * @param[in] tag The handle to media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_tag_insert_to_db() + * + */ +int media_tag_delete_from_db(int tag_id); + +/** + * @brief Gets the number of tag for the passed @a filter from the media database. + * + * @param[in] filter The handle to filter + * @param[out] tag_count The count of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_tag_get_tag_count_from_db(filter_h filter, int *tag_count); + +/** + * @brief Iterates through tags from the media database. + * @details This function gets all tags meeting a desired @a filter + * and calls a registered callback function for every retrieved tag. If NULL is passed to the @a filter, no filtering is applied. + * + * @param[in] filter The handle to tag filter + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_tag_cb(). + * @see media_content_connect() + * @see #media_tag_cb + * @see media_filter_create() + * + */ +int media_tag_foreach_tag_from_db (filter_h filter, media_tag_cb callback, void *user_data); + +/** + * @brief Gets the number of media files for the passed @a filter in the given @a tag from the media database. + * + * @param[in] tag_id The ID of media tag + * @param[in] filter The handle to media filter + * @param[out] media_count The count of media items + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_DB_FAILED DB operation failed + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * + */ +int media_tag_get_media_count_from_db (int tag_id, filter_h filter, int *media_count); + +/** + * @brief Iterates through media items for a given tag from the media database. + * @details This function gets all media items associated with a given tag and + * meeting a desired @a filter and calls a registered callback function for + * every retrieved media item. If NULL is passed to the @a filter, no filtering is applied. + * + * @param[in] tag_id The ID of media tag + * @param[in] filter The handle to media filter + * @param[in] callback The callback function to invoke + * @param[in] user_data The user data to be passed to the callback function + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post This function invokes media_info_cb(). + * @see media_content_connect() + * @see #media_info_cb + * @see media_filter_create() + */ +int media_tag_foreach_media_from_db(int tag_id, filter_h filter, media_info_cb callback, void *user_data); + +/** + * @brief Clones the media tag. + * @details This function copies the media tag handle from a source to destination. + * There is no media_tag_create() function. The media_tag_h is created internally and available through media tag foreach function + * such as media_tag_foreach_tag_from_db(). + * To use this handle outside of these foreach functions, use this function. + * @remark The destination handle must be released with media_tag_destroy() by you. + * + * @param[out] dst A destination handle to media tag + * @param[in] src The source handle to media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @see media_tag_destroy() + * + */ +int media_tag_clone(media_tag_h *dst, media_tag_h src); + +/** + * @brief Destroys the media tag. + * @details This function frees all resources related to the tag handle. The tag handle can no longer + * be used for any operation. A new tag handle has to be created before next usage. + * + * @param[in] tag The media tag handle + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre A copy of the media tag handle created by calling media_tag_clone() or media_tag_insert_to_db() + * @see media_tag_clone() + * @see media_tag_insert_to_db() + * + */ +int media_tag_destroy(media_tag_h tag); + +/** + * @brief Gets media tag's ID. + * + * + * @param [in] tag The handle to media tag + * @param [out] tag_id The ID of media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int media_tag_get_tag_id(media_tag_h tag, int *tag_id); + +/** + * @brief Gets the tag name. + * + * @remarks @a tag_name must be released with free() by you. + * + * @param[in] tag The handle to media tag + * @param[out] tag_name The name of the tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * + */ +int media_tag_get_name(media_tag_h tag, char **tag_name); + +/** + * @brief Gets the media tag from the media database. + * + * @details This function creates a new media tag handle from the media database by the given tag_id. + * media tag will be created, which is filled with tag information. + * + * @remarks @a folder must be released with media_tag_destroy() by you. + * + * @param[in] tag_id The ID of media tag + * @param[out] tag The media tag handle associated with the tag ID + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_tag_destroy() + * + */ +int media_tag_get_tag_from_db(int tag_id, media_tag_h *tag); + +/** + * @brief Adds a new media info to the tag. + * + * @param[in] tag The handle to media tag + * @param[in] media_id The ID to media info which is added + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post media_tag_update_to_db() + * @see media_content_connect() + * @see media_tag_remove_media() + * + */ +int media_tag_add_media(media_tag_h tag, const char *media_id); + +/** + * @brief Removes the media info from the given tag. + * + * @param[in] tag The handle to media tag + * @param[in] media_id The ID to media info which is removed + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @pre This function requires opened connection to content service by media_content_connect(). + * @post media_tag_update_to_db() + * @see media_content_connect() + * @see media_tag_add_media() + * + */ +int media_tag_remove_media(media_tag_h tag, const char *media_id); + +/** + * @brief Sets the tag name. + * + * @param[in] tag The handle to media tag + * @param[in] tag_name The name of the media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @post media_tag_update_to_db() + * + */ +int media_tag_set_name(media_tag_h tag, char *tag_name); + +/** + * @brief Updates the media tag to the media database. + * + * @details The function updates the given media tag in the media database. The function should be called after any change in tag attributes, to be updated to the media + * database. For example, after using media_tag_set_name() for setting the name of the tag, media_tag_update_to_db() function should be called so as to update + * the given tag attibutes in the media database. + * + * @param[in] tag The handle to media tag + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_tag_destroy() + * @see media_tag_add_media() + * @see media_tag_remove_media() + * @see media_tag_set_name() + * + */ +int media_tag_update_to_db(media_tag_h tag); + +/** + * @} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_TAG_H__ */ diff --git a/include/media_util_private.h b/include/media_util_private.h new file mode 100755 index 0000000..f4acbbe --- /dev/null +++ b/include/media_util_private.h @@ -0,0 +1,40 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 __TIZEN_MEDIA_UTIL_PRIVATE_H__ +#define __TIZEN_MEDIA_UTIL_PRIVATE_H__ + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + *@internal + */ +int _media_util_get_store_type_by_path(const char *path, int *storage_type); + +/** + *@internal + */ +int _media_util_get_file_dir_modified_time(const char *path); + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*__TIZEN_MEDIA_UTIL_PRIVATE_H__*/ diff --git a/include/media_video.h b/include/media_video.h index 70d21e0..c657755 100644..100755 --- a/include/media_video.h +++ b/include/media_video.h @@ -11,7 +11,7 @@ * 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. +* limitations under the License. */ @@ -36,19 +36,18 @@ extern "C" { * @details This function copies the video metadata handle from a source to * destination. - * @remark The destination handle must be released with video_meta_destroy() by you. + * @remark The destination handle must be released with video_meta_destroy() by you. * * @param [out] dst A destination handle to video metadata * @param [in] src The source handle to video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory * @see video_meta_destroy() */ int video_meta_clone(video_meta_h *dst, video_meta_h src); - /** * @brief Destroys video metadata. * @details Function frees all resources related to video metadata handle. This handle @@ -65,37 +64,37 @@ int video_meta_clone(video_meta_h *dst, video_meta_h src); */ int video_meta_destroy(video_meta_h video); - /** - * @brief Gets the longitude from video metadata. - * @details Function gives geographic position: @a longitude in degrees, - * which is positive for east and negative for west. + * @brief Gets id of media of given video metadata. + * + * @remarks @a media id must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] longitude The video longitude in degrees + * @param [out] media_id The id of the video * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_longitude(video_meta_h video, double *longitude); - +int video_meta_get_media_id(video_meta_h video, char **media_id); /** - * @brief Gets the latitude from video metadata. - * @details Function gives geographic position: @a latitude in degrees, - * which is positive for north and negative for south. + * @brief Gets the video's title. + * + * @remarks @a title must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] latitude The video latitude in degrees + * @param [out] title The title of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_latitude(video_meta_h video, double *latitude); - +int video_meta_get_title(video_meta_h video, char **title); /** * @brief Gets the video's album. + * If the value is an empty string, the method returns "Unknown". * * @remarks @a album must be released with free() by you. * @@ -108,9 +107,9 @@ int video_meta_get_latitude(video_meta_h video, double *latitude); */ int video_meta_get_album(video_meta_h video, char **album); - /** * @brief Gets the video's artist. + * If the value is an empty string, the method returns "Unknown". * * @remarks @a artist must be released with free() by you. * @@ -123,272 +122,236 @@ int video_meta_get_album(video_meta_h video, char **album); */ int video_meta_get_artist(video_meta_h video, char **artist); - /** - * @brief Gets the video's title. + * @brief Gets the video's genre. + * If the value is an empty string, the method returns "Unknown". * - * @remarks @a title must be released with free() by you. + * @remarks @a genre must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] title The title of video metadata + * @param [out] genre The genre of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_title(video_meta_h video, char **title); - +int video_meta_get_genre(video_meta_h video, char **genre); /** - * @brief Gets the video's description. + * @brief Gets the video's composer. + * If the value is an empty string, the method returns "Unknown". * - * @remarks @a description must be released with free() by you. + * @remarks @a composer must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] description The description of video metadata + * @param [out] composer The composer of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_description(video_meta_h video, char **description); - +int video_meta_get_composer(video_meta_h video, char **composer); /** - * @brief Gets the video's time played parameter. - * @details Function returns video's elapsed playback time parameter as period - * starting from the beginning of the movie. + * @brief Gets the video's year. + * If the value is an empty string, the method returns "Unknown". + * + * @remarks @a year must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] time_played The time period from the beginning of the video (in milliseconds) + * @param [out] year The year of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @see video_meta_update_time_played_to_db() + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_time_played(video_meta_h video, int *time_played); - +int video_meta_get_year(video_meta_h video, char **year); /** - * @brief Gets duration of video metadata. + * @brief Gets the video's recorded_date. + * + * @remarks @a recorded_date must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] duration The video duration in milliseconds + * @param [out] recorded_date The recorded_date of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_duration(video_meta_h video, int *duration); - +int video_meta_get_recorded_date(video_meta_h video, char **recorded_date); /** - * @brief Gets the video's width in pixels. + * @brief Gets the video's copyright. + * + * @remarks @a copyright must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] width The video width in pixels + * @param [out] copyright The copyright of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_width(video_meta_h video, int *width); - +int video_meta_get_copyright(video_meta_h video, char **copyright); /** - * @brief Gets the video's height in pixels. + * @brief Gets the video's track number. + * If the value is an empty string, the method returns "Unknown". + * + * @remarks @a track_num must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] height The video height in pixels + * @param [out] track_num The track number of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_height(video_meta_h video, int *height); - +int video_meta_get_track_num(video_meta_h video, char **track_num); /** - * @brief Gets the video's orientation. + * @brief Gets the video's bit rate. + * + * @remarks @a bit_rate must be released with free() by you. * * @param [in] video The handle to video metadata - * @param [out] orientation The orientation of video metadata + * @param [out] bit_rate The bit rate of video metadata * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory */ -int video_meta_get_orientation(video_meta_h video, media_content_orientation_e *orientation); - +int video_meta_get_bit_rate(video_meta_h video, int *bit_rate); /** - * @brief Gets the date, when video was created + * @brief Gets duration of video metadata. * * @param [in] video The handle to video metadata - * @param [out] date_taken The date, when video was taken (in seconds, since the Epoch) + * @param [out] duration The video duration in milliseconds * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ -int video_meta_get_date_taken(video_meta_h video, time_t *date_taken); - +int video_meta_get_duration(video_meta_h video, int *duration); /** - * @brief Updates video's time played parameter to the media database. - * @details Function updates video's time played parameter - * This parameter describes elapsed playback time, starting from the - * beginning of the movie. + * @brief Gets the video's width in pixels. * * @param [in] video The handle to video metadata - * @param [in] time_played The video time played (in milliseconds) + * @param [out] width The video width in pixels * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see video_meta_get_time_played() - */ -int video_meta_update_time_played_to_db(video_meta_h video, int time_played); - - -/** - *@} */ +int video_meta_get_width(video_meta_h video, int *width); /** - * @addtogroup CAPI_CONTENT_MEDIA_VIDEO_BOOKMARK_MODULE - * @{ + * @brief Gets the video's height in pixels. + * + * @param [in] video The handle to video metadata + * @param [out] height The video height in pixels + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter */ - +int video_meta_get_height(video_meta_h video, int *height); /** - * @brief Iterates through video bookmarks with optional filter in the given video metadata from the media database. - * @details This function gets all video bookmarks associated with the given folder and meeting desired filter option and -calls registered callback function for every retrieved item. If NULL is passed to the @a filter, no filtering is applied. - * @remarks Only start position and offset details of filter can be set, - * because searching by bookmark name information is not supported. + * @brief Gets the video's played count. * * @param [in] video The handle to video metadata - * @param [in] filter The handle to video bookmark filter - * @param [in] callback The callback function to invoke - * @param [in] user_data The user data to be passed to the callback function - + * @param [out] played_count The number of played * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory - * @pre This function requires opened connection to content service by media_content_connect(). - * @post This function invokes video_bookmark_cb(). - * @see media_content_connect() - * @see #video_bookmark_cb - * @see video_bookmark_filter_create() - * */ -int video_bookmark_foreach_bookmark_from_db(video_meta_h video, video_bookmark_filter_h filter, video_bookmark_cb callback, void *user_data); - +int video_meta_get_played_count(video_meta_h video, int *played_count); /** - * @brief Clones video bookmark. - * @details This function copies the video bookmark handle from a source to destination. There is no video_bookmark_create() function. - * The video_bookmark_h is created internally and available through video bookmark foreach function such as video_bookmark_foreach_bookmark_from_db(). - * To use this handle outside of these foreach functions, use this function. - * - * @remark The destination handle must be released with video_bookmark_destroy() by you. + * @brief Gets the video's time last played parameter. * - * @param [out] dst A destination handle to video bookmark - * @param [in] src The source handle to video bookmark + * @param [in] video The handle to video metadata + * @param [out] played_time The time last played in the video * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory - * @see video_bookmark_destroy() - * @see video_bookmark_foreach_bookmark_from_db() - * */ -int video_bookmark_clone(video_bookmark_h *dst, video_bookmark_h src); - +int video_meta_get_played_time(video_meta_h video, time_t *played_time); /** - * @brief Destroys video bookmark. - * @details Function frees all resources related to bookmark handle. This handle - * no longer can be used to perform any operation. A new handle has to - * be created before the next use. + * @brief Gets the video's position played parameter. + * @details Function returns video's elapsed playback time parameter as period + * starting from the beginning of the movie. * - * @param [in] bookmark The handle to video bookmark + * @param [in] video The handle to video metadata + * @param [out] played_position The position from the beginning of the video (in milliseconds) * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre Get copy of bookmark handle by calling video_bookmark_clone() - * @see video_bookmark_clone() */ -int video_bookmark_destroy(video_bookmark_h bookmark); - +int video_meta_get_played_position(video_meta_h video, int *played_position); /** - * @brief Gets bookmark's time marked parameter. - * @details Function returns time offset in milliseconds from beginning of the movie on which bookmark - * was placed. + * @brief Sets the video's played count. * - * @param [in] bookmark The handle to video bookmark - * @param [out] time_marked The bookmark time offset (in milliseconds) + * @param [in] video The handle to video metadata + * @param [in] played_count The number of played * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * @post video_meta_update_to_db() */ -int video_bookmark_get_time_marked(video_bookmark_h bookmark, time_t *time_marked); - +int video_meta_set_played_count(video_meta_h video, int played_count); /** - * @brief Gets the video bookmark's thumbnail - * - * @remarks thumbnail must be released with free() by you. + * @brief Sets the video's time last played parameter. * - * @param [in] bookmark The handle to video bookmark - * @param [out] thumbnail_path The thumbnail path of video bookmark + * @param [in] video The handle to video metadata + * @param [in] played_time The time last played in the video * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #MEDIA_CONTENT_ERROR_OUT_OF_MEMORY Out of memory + * @post video_meta_update_to_db() */ -int video_bookmark_get_thumbnail_path(video_bookmark_h bookmark, char **thumbnail_path); - +int video_meta_set_played_time(video_meta_h video, time_t played_time); /** - * @brief Inserts a new bookmark in video on specified time offset to the media database. + * @brief Sets the video's position played parameter. + * @details Function returns video's elapsed playback time parameter as period + * starting from the beginning of the movie. * * @param [in] video The handle to video metadata - * @param [in] time The bookmark time offset (in seconds) - * @param [in] thumbnail_path The thumbnail path of video bookmark. + * @param [in] played_position The position from the beginning of the video (in milliseconds) * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter - * @pre This function requires opened connection to content service by media_content_connect(). - * @see media_content_connect() - * @see video_bookmark_delete_from_db() - * + * @post video_meta_update_to_db() */ -int video_bookmark_insert_to_db(video_meta_h video, time_t time, const char *thumbnail_path); - +int video_meta_set_played_position(video_meta_h video, int played_position); /** - * @brief Removes video bookmark from the media database. + * @brief Updates the video to the media database. + * + * @details The function updates the given video meta in the media database. The function should be called after any change in video attributes, to be updated to the media + * database. For example, after using video_meta_set_orientation() for setting the orientation of the video, video_meta_update_to_db() function should be called so as to update + * the given video attibutes in the media database. * - * @param [in] bookmark The handle to video bookmark + * @param[in] image The handle to image * @return 0 on success, otherwise a negative error value. * @retval #MEDIA_CONTENT_ERROR_NONE Successful * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter * @pre This function requires opened connection to content service by media_content_connect(). * @see media_content_connect() - * @see video_bookmark_insert_to_db() - * + * @see video_meta_set_orientation() */ -int video_bookmark_delete_from_db(video_bookmark_h bookmark); - - +int video_meta_update_to_db(video_meta_h video); /** - * @} + *@} */ #ifdef __cplusplus } #endif /* __cplusplus */ #endif /*__TIZEN_VIDEO_META_H__*/ - - diff --git a/packaging/capi-content-media-content.spec b/packaging/capi-content-media-content.spec index ba6fd86..b29ecc8 100644..100755 --- a/packaging/capi-content-media-content.spec +++ b/packaging/capi-content-media-content.spec @@ -1,16 +1,16 @@ +#sbs-git:slp/api/media-content capi-content-media-content 0.1.0 718ef86b8c37cf9e8f110ada62eed01ab9d9e2f6 Name: capi-content-media-content Summary: A Media content library in SLP C API -Version: 0.1.0 -Release: 19 -Group: TO_BE/FILLED_IN +Version: 0.2.13 +Release: 1 +Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz BuildRequires: cmake BuildRequires: pkgconfig(dlog) -BuildRequires: pkgconfig(drm-service) -BuildRequires: pkgconfig(aul) BuildRequires: pkgconfig(capi-base-common) BuildRequires: pkgconfig(libmedia-service) +BuildRequires: pkgconfig(libmedia-utils) Requires(post): /sbin/ldconfig @@ -20,8 +20,8 @@ Requires(postun): /sbin/ldconfig %package devel -Summary: A Media content library in Tizen Native API (Development) -Group: TO_BE/FILLED_IN +Summary: A Media content library in SLP C API (Development) +Group: Development/Libraries Requires: %{name} = %{version}-%{release} %description devel diff --git a/src/media_audio.c b/src/media_audio.c index c4c4ba4..651b6bf 100644..100755 --- a/src/media_audio.c +++ b/src/media_audio.c @@ -1,2568 +1,718 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <media_content.h>
-#include <media-svc.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <media_info_private.h>
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-int audio_meta_destroy(audio_meta_h audio)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if(_audio->audio_id)
- {
- free(_audio->audio_id);
- }
- if(_audio->genre)
- {
- free(_audio->genre);
- }
- if(_audio->author)
- {
- free(_audio->author);
- }
- if(_audio->copyright)
- {
- free(_audio->copyright);
- }
- if(_audio->description)
- {
- free(_audio->description);
- }
- if(_audio->format)
- {
- free(_audio->format);
- }
-
- free(_audio);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-
-int audio_meta_clone(audio_meta_h* dst, audio_meta_h src)
-{
- int ret;
- audio_meta_s* _src = (audio_meta_s*)src;
-
- if(_src != NULL)
- {
-
- audio_meta_s* _dst = (audio_meta_s*)calloc(1,sizeof(audio_meta_s));
-
- if(_dst == NULL)
- {
-
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _dst->audio_id = strdup(_src->audio_id);
- if(_dst->audio_id == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _dst->year= _src->year;
- _dst->bitrate = _src->bitrate;
- _dst->track_num = _src->track_num ;
- _dst->duration = _src->duration;
- _dst->rating = _src->rating;
- _dst->count_played = _src->count_played;
- _dst->time_played = _src->time_played;
- _dst->time_added = _src->time_added;
- _dst->size = _src->size;
- _dst->category = _src->category;
-
- if((_src->album != NULL) && (strlen(_src->album) > 0))
- {
- _dst->album = strdup(_src->album);
- if(_dst->album == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if((_src->artist != NULL) && (strlen(_src->artist) > 0))
- {
- _dst->artist = strdup(_src->artist);
- if(_dst->artist == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if((_src->author != NULL) && (strlen(_src->author) > 0))
- {
- _dst->author = strdup(_src->author);
- if(_dst->author == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if((_src->genre != NULL) && (strlen(_src->genre) > 0))
- {
- _dst->genre = strdup(_src->genre);
- if(_dst->genre == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- if((_src->author != NULL) && (strlen(_src->author ) > 0))
- {
- _dst->author = strdup(_src->author );
- if(_dst->author == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->copyright != NULL) && (strlen(_src->copyright) > 0))
- {
- _dst->copyright = strdup(_src->copyright);
- if(_dst->copyright == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->description != NULL) && (strlen(_src->description) > 0))
- {
- _dst->description = strdup(_src->description);
- if(_dst->description == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->format != NULL) && (strlen(_src->format) > 0))
- {
- _dst->format = strdup(_src->format);
- if(_dst->format == NULL)
- {
- audio_meta_destroy((audio_meta_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- *dst = (audio_meta_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_meta_get_genre(audio_meta_h audio, char** name)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->genre != NULL) && (strlen(_audio->genre) > 0))
- {
- *name = strdup(_audio->genre);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-int audio_meta_get_album(audio_meta_h audio, char **name)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->album != NULL) && (strlen(_audio->album) > 0))
- {
- *name = strdup(_audio->album);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-int audio_meta_get_artist(audio_meta_h audio, char **name)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->artist != NULL) && (strlen(_audio->artist) > 0))
- {
- *name = strdup(_audio->artist);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-
-}
-
-int audio_meta_get_author(audio_meta_h audio, char** name)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->author != NULL) && (strlen(_audio->author) > 0))
- {
- *name = strdup(_audio->author);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_meta_get_year(audio_meta_h audio,char** year)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->year != NULL) && (strlen(_audio->year) > 0))
- {
- *year = strdup(_audio->year);
- if(*year == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *year = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-int audio_meta_get_copyright(audio_meta_h audio, char** copyright)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->copyright != NULL) && (strlen(_audio->copyright) > 0))
- {
- *copyright = strdup(_audio->copyright);
- if(*copyright == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *copyright = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-
-int audio_meta_get_description(audio_meta_h audio, char** description)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->description != NULL) && (strlen(_audio->description) > 0))
- {
- *description = strdup(_audio->description);
- if(*description == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *description = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-}
-
-
-int audio_meta_get_format(audio_meta_h audio, char** format)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- if((_audio->format != NULL) && (strlen(_audio->format) > 0))
- {
- *format = strdup(_audio->format);
- if(*format == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *format = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_meta_get_bitrate(audio_meta_h audio,int* bitrate)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio && bitrate)
- {
- *bitrate = _audio->bitrate;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_track_num(audio_meta_h audio,int* track_num)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio && track_num)
- {
- *track_num = _audio->track_num;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_duration(audio_meta_h audio,int* duration)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *duration = _audio->duration;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_rating(audio_meta_h audio,int* rating)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *rating= _audio->rating;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_count_played(audio_meta_h audio,int* count_played)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *count_played = _audio->count_played;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_time_played(audio_meta_h audio,int* time_played)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *time_played = _audio->time_played;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_time_added(audio_meta_h audio,time_t* time_added)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *time_added = _audio->time_added;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_size(audio_meta_h audio,int* size)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *size = _audio->size;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_get_category(audio_meta_h audio,audio_category_e* category)
-{
- int ret;
- audio_meta_s* _audio = (audio_meta_s*)audio;
- if(_audio)
- {
- *category = _audio->category;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_meta_update_count_played_to_db(audio_meta_h audio,int count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- audio_meta_s* _audio = (audio_meta_s*)audio;
-
-
- if(_audio != NULL)
- {
- ret = audio_svc_update_item_metadata(_content_get_db_handle(),_audio->audio_id,AUDIO_SVC_TRACK_DATA_PLAYED_COUNT,count,-1);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-int audio_meta_update_time_played_to_db(audio_meta_h audio,time_t time)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- audio_meta_s* _audio = (audio_meta_s*)audio;
-
-
- if(_audio != NULL)
- {
- ret = audio_svc_update_item_metadata(_content_get_db_handle(),_audio->audio_id,AUDIO_SVC_TRACK_DATA_PLAYED_TIME,time,-1);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-
-int audio_playlist_foreach_playlist_from_db(media_audio_filter_h filter, audio_playlist_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- if( callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- if((media_audio_filter_s*)filter != _filter)
- {
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- }
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_PLAYLIST);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- return ret;
- }
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- audio_playlist_s* playlist = (audio_playlist_s*)calloc(1,sizeof(audio_playlist_s));
- if(playlist == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- playlist->playlist_id= (int)sqlite3_column_int(stmt,0);
- playlist->name= strdup((const char *)sqlite3_column_text(stmt, 1));
- if(callback((audio_playlist_h)playlist,user_data) == false)
- {
- audio_playlist_destroy((audio_playlist_h)playlist);
- break;
- }
- audio_playlist_destroy((audio_playlist_h)playlist);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-
-int audio_playlist_foreach_media_from_db(audio_playlist_h playlist, media_audio_filter_h filter, media_info_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
-
- if(_playlist == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- if(callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query),
- " and display_name like '%%%s%%' ",
- _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query, sizeof(select_query),SELECT_MEDIA_FROM_PLAYLIST, _playlist->playlist_id);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item = (media_info_s*)calloc(1,sizeof(media_info_s));
- if(item == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _content_item_get_detail(stmt,(media_info_h)item);
- if(callback((media_info_h)item,user_data) == false )
- {
- media_info_destroy((media_info_h)item);
- break;
- }
- media_info_destroy((media_info_h)item);
-
- }
-
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
-
- return ret;
-}
-
-int audio_playlist_get_media_count_from_db(audio_playlist_h playlist,int* count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
-
- if(_playlist != NULL)
- {
- ret = audio_svc_count_playlist_item(_content_get_db_handle(),_playlist->playlist_id,NULL,NULL, count);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int audio_playlist_insert_to_db(const char* name, audio_playlist_h* playlist)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- int playlist_id;
-
- if(name != NULL)
- {
- audio_playlist_s* _playlist = (audio_playlist_s*)calloc(1,sizeof(audio_playlist_s));
-
- if( _playlist == NULL )
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
-
- ret = audio_svc_add_playlist(_content_get_db_handle(),name,&playlist_id);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- free(_playlist);
- return ret;
- }
-
- _playlist->playlist_id = playlist_id;
- _playlist->name = strdup(name);
- if(_playlist->name == NULL)
- {
- free(_playlist);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- *playlist = (audio_playlist_h)_playlist;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int audio_playlist_delete_from_db(audio_playlist_h playlist)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
-
- if(_playlist != NULL)
- {
- ret = audio_svc_delete_playlist(_content_get_db_handle(),_playlist->playlist_id);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-int audio_playlist_destroy(audio_playlist_h playlist)
-{
- int ret;
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
- if(_playlist)
- {
- if(_playlist->name)
- {
- free(_playlist->name);
- }
-
- free(_playlist);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-int audio_playlist_clone(audio_playlist_h* dst, audio_playlist_h src)
-{
- int ret;
- audio_playlist_s* _src = (audio_playlist_s*)src;
-
- if(_src != NULL )
- {
- audio_playlist_s* _dst = (audio_playlist_s*)calloc(1,sizeof(audio_playlist_s));
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _dst->playlist_id = _src->playlist_id;
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- audio_playlist_destroy((audio_playlist_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- *dst = (audio_playlist_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_playlist_get_name(audio_playlist_h playlist,char** name)
-{
- int ret;
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
- if(_playlist)
- {
- if((_playlist->name!= NULL) && (strlen(_playlist->name) > 0))
- {
- *name = strdup(_playlist->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-
-int audio_playlist_update_name_to_db(audio_playlist_h playlist,const char* name)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
-
-
- if(_playlist != NULL && name != NULL)
- {
- ret = audio_svc_update_playlist_name(_content_get_db_handle(),_playlist->playlist_id,name);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- {
- free(_playlist->name);
- _playlist->name = strdup(name);
- if(_playlist->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
-
- return ret;
-}
-
-int audio_playlist_add_media_to_db(audio_playlist_h playlist, media_info_h item)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
- media_info_s* _item = (media_info_s*)item;
-
- if(_playlist != NULL && _item != NULL && _item->media_type == 4)
- {
-
- ret = audio_svc_add_item_to_playlist(_content_get_db_handle(),_playlist->playlist_id,_item->item_id);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
-
-int audio_playlist_remove_media_from_db(audio_playlist_h playlist, media_info_h item)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- audio_playlist_s* _playlist = (audio_playlist_s*)playlist;
- media_info_s* _item = (media_info_s*)item;
-
- if(_playlist != NULL && _item != NULL && _item->media_type == 4)
- {
-
- ret = audio_svc_remove_item_from_playlist_by_audio_id(_content_get_db_handle(),_playlist->playlist_id,_item->item_id);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
-
- return ret;
-}
-
-int audio_genre_foreach_genre_from_db(media_audio_filter_h filter, audio_genre_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
-
- media_audio_filter_s* _filter = NULL;
-
-
- if(callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_GENRE_LIST);
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- audio_genre_s* genre = (audio_genre_s*)calloc(1,sizeof(audio_genre_s));
- memset(genre,0x00,sizeof(audio_genre_s));
- genre->name= strdup((const char *)sqlite3_column_text(stmt, 0));
- if(callback((audio_genre_h)genre,user_data) == false)
- {
- audio_genre_destroy((audio_genre_h)genre);
- break;
- }
- audio_genre_destroy((audio_genre_h)genre);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-int audio_genre_foreach_media_from_db(audio_genre_h genre, media_audio_filter_h filter, media_info_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- audio_genre_s* _genre = (audio_genre_s*)genre;
-
-
- if(_genre == NULL || callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(select_query, sizeof(select_query),SELECT_MEDIA_FROM_GENRE, _genre->name);
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret= _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item = (media_info_s*)calloc(1,sizeof(media_info_s));
-
- _content_item_get_detail(stmt, (media_info_h)item);
- if(callback((media_info_h)item,user_data) == false)
- {
- media_info_destroy((media_info_h)item);
- break;
- }
- media_info_destroy((media_info_h)item);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-}
-
-
-int audio_genre_get_media_count_from_db(audio_genre_h genre,int* count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- audio_genre_s* _genre = (audio_genre_s*)genre;
-
-
- memset(select_query,0x00,sizeof(select_query));
-
- if(_genre == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(select_query,sizeof(select_query),SELECT_MEDIA_COUNT_FROM_GENRE,_genre->name);
-
-
- ret = _content_query_prepare(&stmt,select_query,NULL,NULL,NULL,NULL);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- *count = (int)sqlite3_column_int(stmt,0);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-int audio_genre_destroy(audio_genre_h genre)
-{
- int ret;
- audio_genre_s* _genre = (audio_genre_s*)genre;
- if(_genre)
- {
- if(_genre->name)
- {
- free(_genre->name);
- }
-
- free(_genre);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-
-int audio_genre_clone(audio_genre_h* dst,audio_genre_h src)
-{
- int ret;
- audio_genre_s* _src = (audio_genre_s*)src;
-
-
- if(_src != NULL)
- {
- audio_genre_s* _dst = (audio_genre_s*)calloc(1,sizeof(audio_genre_s));
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- audio_genre_destroy((audio_genre_h)_dst);
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *dst = (audio_genre_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_genre_get_name(audio_genre_h genre, char** name)
-{
- int ret;
- audio_genre_s* _genre = (audio_genre_s*)genre;
- if(_genre)
- {
- if((_genre->name!= NULL) && (strlen(_genre->name) > 0))
- {
- *name = strdup(_genre->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_album_foreach_album_from_db(media_audio_filter_h filter, audio_album_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
-
- if(callback == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'",_filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
- snprintf(select_query,sizeof(select_query),"%s", SELECT_ALBUM_LIST);
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- audio_album_s* album = (audio_album_s*)calloc(1,sizeof(audio_album_s));
-
- if(album == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- album->name= strdup((const char *)sqlite3_column_text(stmt, 0));
- if(callback((audio_album_h)album,user_data) == false)
- {
- audio_album_destroy((audio_album_h)album);
- break;
- }
- audio_album_destroy((audio_album_h)album);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
- return ret;
-
-}
-
-int audio_album_foreach_media_from_db(audio_album_h album, media_audio_filter_h filter, media_info_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
-
- audio_album_s* _album = (audio_album_s*)album;
-
-
- if( _album == NULL || callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query, sizeof(select_query),SELECT_MEDIA_FROM_ALBUM, _album->name);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item = (media_info_s*)calloc(1,sizeof(media_info_s));
-
- _content_item_get_detail(stmt, (media_info_h)item);
- if(callback((media_info_h)item,user_data) == false)
- {
- media_info_destroy((media_info_h)item);
- break;
- }
- media_info_destroy((media_info_h)item);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-
-}
-
-
-int audio_album_get_media_count_from_db(audio_album_h album,int* count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- sqlite3_stmt *stmt = NULL;
- audio_album_s* _album = (audio_album_s*)album;
- char select_query[DEFAULT_QUERY_SIZE];
-
- memset(select_query,0x00,sizeof(select_query));
-
- if(_album == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(select_query,sizeof(select_query),SELECT_MEDIA_COUNT_FROM_ALBUM,_album ->name);
-
-
- ret = _content_query_prepare(&stmt,select_query,NULL,NULL,NULL,NULL);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- *count = (int)sqlite3_column_int(stmt,0);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
-
- return ret;
-
-}
-
-int audio_album_destroy(audio_album_h album )
-{
- int ret;
- audio_album_s* _album = (audio_album_s*)album;
- if(_album)
- {
- if(_album->name)
- {
- free(_album->name);
- }
-
- free(_album);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-
-int audio_album_clone(audio_album_h* dst,audio_album_h src)
-{
- int ret;
- audio_album_s* _src = (audio_album_s*)src;
-
-
- if(_src != NULL)
- {
- audio_album_s* _dst = (audio_album_s*)calloc(1,sizeof(audio_album_s));
-
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- audio_album_destroy((audio_album_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *dst = (audio_album_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-int audio_album_get_name(audio_album_h album, char** name)
-{
- int ret;
- audio_album_s* _album = (audio_album_s*)album;
- if(_album)
- {
- if((_album->name!= NULL) && (strlen(_album->name) > 0))
- {
- *name = strdup(_album->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-int audio_author_foreach_author_from_db(media_audio_filter_h filter, audio_author_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- if(callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_AUTHOR_LIST);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME,QUERY_KEYWORD_DESC);
- }
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- audio_author_s* author = (audio_author_s*)calloc(1,sizeof(audio_author_s));
- if(author == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- author->name= strdup((const char *)sqlite3_column_text(stmt, 0));
- if(callback((audio_author_h)author,user_data) == false)
- {
- audio_author_destroy((audio_author_h)author);
- break;
- }
- audio_author_destroy((audio_author_h)author);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
- return ret;
-
-}
-
-int audio_author_foreach_media_from_db(audio_author_h author, media_audio_filter_h filter, media_info_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- audio_author_s* _author = (audio_author_s*)author;
-
-
- if(_author == NULL || callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query, sizeof(select_query),SELECT_MEDIA_FROM_AUTHOR, _author->name);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret =_content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item = (media_info_s*)calloc(1,sizeof(media_info_s));
- if(item == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _content_item_get_detail(stmt, (media_info_h)item);
- if(callback((media_info_h)item,user_data) == false)
- {
- media_info_destroy((media_info_h)item);
- break;
- }
- media_info_destroy((media_info_h)item);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-
-}
-
-
-int audio_author_get_media_count_from_db(audio_author_h author,int* count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- sqlite3_stmt *stmt = NULL;
- audio_author_s* _author = (audio_author_s*)author;
- char select_query[DEFAULT_QUERY_SIZE];
-
-
- memset(select_query,0x00,sizeof(select_query));
-
- if(_author == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- snprintf(select_query,sizeof(select_query),SELECT_MEDIA_COUNT_FROM_AUTHOR,_author ->name);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,NULL,NULL,NULL);
- if(ret!= MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- *count = (int)sqlite3_column_int(stmt,0);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
-
- return ret;
-
-}
-
-int audio_author_destroy(audio_author_h author )
-{
- int ret;
- audio_author_s* _author = (audio_author_s*)author;
- if(_author)
- {
- if(_author->name)
- {
- free(_author->name);
- }
-
- free(_author);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-
-int audio_author_clone(audio_author_h* dst,audio_author_h src)
-{
- int ret;
- audio_author_s* _src = (audio_author_s*)src;
-
-
- if(_src != NULL)
- {
- audio_author_s* _dst = (audio_author_s*)calloc(1,sizeof(audio_author_s));
-
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- audio_author_destroy((audio_author_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *dst = (audio_author_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-int audio_author_get_name(audio_author_h author, char** name)
-{
- int ret;
- audio_author_s* _author = (audio_author_s*)author;
- if(_author)
- {
- if((_author->name!= NULL) && (strlen(_author->name) > 0))
- {
- *name = strdup(_author->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-
-
-int audio_artist_foreach_artist_from_db(media_audio_filter_h filter, audio_artist_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- if(callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_MEDIA_ARTIST_LIST);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ADDED_TIME,QUERY_KEYWORD_DESC);
- }
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
- ret =_content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- audio_artist_s* artist = (audio_artist_s*)calloc(1,sizeof(audio_artist_s));
- if(artist == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- artist->name= strdup((const char *)sqlite3_column_text(stmt, 0));
- if(callback((audio_artist_h)artist,user_data) == false)
- {
- audio_artist_destroy((audio_artist_h)artist);
- break;
- }
- audio_artist_destroy((audio_artist_h)artist);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-int audio_artist_foreach_media_from_db(audio_artist_h artist, media_audio_filter_h filter, media_info_cb callback, void* user_data )
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char order_query[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_audio_filter_s* _filter = NULL;
-
- audio_artist_s* _artist = (audio_artist_s*)artist;
-
-
- if(_artist == NULL || callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- if(filter != NULL)
- _filter = (media_audio_filter_s*)filter;
- else
- {
- media_audio_filter_create((media_audio_filter_h*)&_filter);
- }
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(order_query,0x00,sizeof(order_query));
- memset(select_query,0x00,sizeof(select_query));
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- snprintf(select_query, sizeof(select_query),SELECT_MEDIA_FROM_ARTIST, _artist->name);
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
- if((media_audio_filter_s*)filter != _filter)
- media_audio_filter_destroy((media_audio_filter_h)_filter);
-
-
- ret= _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item = (media_info_s*)calloc(1,sizeof(media_info_s));
- if(item == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _content_item_get_detail(stmt, (media_info_h)item);
- if(callback((media_info_h)item,user_data) == false)
- {
- media_info_destroy((media_info_h)item);
- break;
- }
- media_info_destroy((media_info_h)item);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-
-}
-
-
-int audio_artist_get_media_count_from_db(audio_artist_h artist,int* count)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- sqlite3_stmt *stmt = NULL;
- audio_artist_s* _artist = (audio_artist_s*)artist;
- char select_query[DEFAULT_QUERY_SIZE];
-
-
- memset(select_query,0x00,sizeof(select_query));
- if(_artist == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(select_query,sizeof(select_query),SELECT_MEDIA_COUNT_FROM_ARTIST,_artist ->name);
-
- ret = _content_query_prepare(&stmt,select_query,NULL, NULL,NULL,NULL);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- *count = (int)sqlite3_column_int(stmt,0);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
-
- return ret;
-
-}
-
-int audio_artist_destroy(audio_artist_h artist )
-{
- int ret;
- audio_artist_s* _artist = (audio_artist_s*)artist;
- if(_artist)
- {
- if(_artist->name)
- {
- free(_artist->name);
- }
-
- free(_artist);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
- return ret;
-
-}
-
-int audio_artist_clone(audio_artist_h* dst,audio_artist_h src)
-{
- int ret;
- audio_artist_s* _src = (audio_artist_s*)src;
-
-
- if(_src != NULL )
- {
-
- audio_artist_s* _dst = (audio_artist_s*)calloc(1,sizeof(audio_artist_s));
-
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- audio_artist_destroy((audio_artist_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *dst = (audio_artist_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-
-}
-
-int audio_artist_get_name(audio_artist_h artist, char** name)
-{
- int ret;
- audio_artist_s* _artist = (audio_artist_s*)artist;
- if(_artist)
- {
- if((_artist->name!= NULL) && (strlen(_artist->name) > 0))
- {
- *name = strdup(_artist->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER ;
- }
-
- return ret;
-}
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> + + +int audio_meta_destroy(audio_meta_h audio) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + SAFE_FREE(_audio->media_id); + SAFE_FREE(_audio->title); + SAFE_FREE(_audio->album); + SAFE_FREE(_audio->artist); + SAFE_FREE(_audio->genre); + SAFE_FREE(_audio->composer); + SAFE_FREE(_audio->year); + SAFE_FREE(_audio->recorded_date); + SAFE_FREE(_audio->copyright); + SAFE_FREE(_audio->track_num); + SAFE_FREE(_audio); + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_clone(audio_meta_h *dst, audio_meta_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_src = (audio_meta_s*)src; + + if(_src != NULL) + { + audio_meta_s *_dst = (audio_meta_s*)calloc(1, sizeof(audio_meta_s)); + + if(_dst == NULL) + { + + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->media_id)) + { + _dst->media_id = strdup(_src->media_id); + if(_dst->media_id == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->title)) + { + _dst->title = strdup(_src->title); + if(_dst->title == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->album)) + { + _dst->album = strdup(_src->album); + if(_dst->album == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->artist)) + { + _dst->artist = strdup(_src->artist); + if(_dst->artist == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->genre)) + { + _dst->genre = strdup(_src->genre); + if(_dst->genre == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->composer)) + { + _dst->composer = strdup(_src->composer); + if(_dst->composer == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->year)) + { + _dst->year = strdup(_src->year); + if(_dst->year == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->recorded_date)) + { + _dst->recorded_date = strdup(_src->recorded_date); + if(_dst->recorded_date == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->copyright)) + { + _dst->copyright = strdup(_src->copyright); + if(_dst->copyright == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->track_num)) + { + _dst->track_num = strdup(_src->track_num); + if(_dst->track_num == NULL) + { + audio_meta_destroy((audio_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->bitrate = _src->bitrate; + _dst->samplerate = _src->samplerate; + _dst->channel = _src->channel; + _dst->duration = _src->duration; + _dst->played_count = _src->played_count; + _dst->played_time = _src->played_time; + _dst->played_position = _src->played_position; + + *dst = (audio_meta_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_media_id(audio_meta_h audio, char **media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->media_id)) + { + *media_id = strdup(_audio->media_id); + if(*media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *media_id = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_title(audio_meta_h audio, char **title) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->title)) + { + *title = strdup(_audio->title); + if(*title == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *title = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_album(audio_meta_h audio, char **album_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->album)) + { + *album_name = strdup(_audio->album); + if(*album_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *album_name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_artist(audio_meta_h audio, char **artist_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + if(STRING_VALID(_audio->artist)) + { + *artist_name = strdup(_audio->artist); + if(*artist_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *artist_name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_genre(audio_meta_h audio, char **genre_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->genre)) + { + *genre_name = strdup(_audio->genre); + if(*genre_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *genre_name = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_composer(audio_meta_h audio, char **composer_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->composer)) + { + *composer_name = strdup(_audio->composer); + if(*composer_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *composer_name = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_year(audio_meta_h audio, char **year) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->year)) + { + *year = strdup(_audio->year); + if(*year == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *year = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_recorded_date(audio_meta_h audio, char **recorded_date) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->recorded_date)) + { + *recorded_date = strdup(_audio->recorded_date); + if(*recorded_date == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *recorded_date = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_copyright(audio_meta_h audio, char **copyright) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->copyright)) + { + *copyright = strdup(_audio->copyright); + if(*copyright == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *copyright = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_track_num(audio_meta_h audio, char **track_num) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + if(_audio) + { + if(STRING_VALID(_audio->track_num)) + { + *track_num = strdup(_audio->track_num); + if(*track_num == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *track_num = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_bit_rate(audio_meta_h audio, int *bit_rate) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio && bit_rate) + { + *bit_rate = _audio->bitrate; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_sample_rate(audio_meta_h audio, int *sample_rate) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio && sample_rate) + { + *sample_rate = _audio->samplerate; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_channel(audio_meta_h audio, int *channel) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio && channel) + { + *channel = _audio->channel; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_duration(audio_meta_h audio, int *duration) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + *duration = _audio->duration; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_played_count(audio_meta_h audio, int *played_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + *played_count = _audio->played_count; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_played_time(audio_meta_h audio, time_t* played_time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + *played_time = _audio->played_time; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_get_played_position(audio_meta_h audio, int *played_position) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(_audio) + { + *played_position = _audio->played_position; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_set_played_count(audio_meta_h audio, int played_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + audio_meta_s *_audio = (audio_meta_s*)audio; + + if((_audio != NULL) && (played_count >= 0)) + { + _audio->played_count = played_count; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_set_played_time(audio_meta_h audio, time_t played_time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + audio_meta_s *_audio = (audio_meta_s*)audio; + + if((_audio != NULL) && (played_time >= 0)) + { + _audio->played_time = played_time; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_set_played_position(audio_meta_h audio, int played_position) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + + if((_audio != NULL) && (played_position >= 0)) + { + _audio->played_position = played_position; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int audio_meta_update_to_db(audio_meta_h audio) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + audio_meta_s *_audio = (audio_meta_s*)audio; + char *sql = NULL; + + if(_audio != NULL && STRING_VALID(_audio->media_id)) + { + sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, _audio->played_count, _audio->played_time, _audio->played_position, _audio->media_id); + ret = _content_query_sql(sql); + sqlite3_free(sql); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} diff --git a/src/media_bookmark.c b/src/media_bookmark.c new file mode 100755 index 0000000..fc64e67 --- /dev/null +++ b/src/media_bookmark.c @@ -0,0 +1,267 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> +#include <media-svc.h> + +int media_bookmark_foreach_bookmark_from_db (filter_h filter, media_bookmark_cb callback, void *user_data); +int media_bookmark_get_media_id(media_bookmark_h bookmark, char **media_id); + +int media_bookmark_insert_to_db(const char *media_id, time_t time, const char *thumbnail_path) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *sql = NULL; + + if(STRING_VALID(media_id)) + { + sql = sqlite3_mprintf(INSERT_BOOKMARK_TO_BOOKMARK, media_id, time, thumbnail_path); + ret = _content_query_sql(sql); + sqlite3_free(sql); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_bookmark_delete_from_db(int bookmark_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + if(bookmark_id < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + query_str = sqlite3_mprintf(DELETE_BOOKMARK_FROM_BOOKMARK, bookmark_id); + + ret = _content_query_sql(query_str); + + sqlite3_free(query_str); + + return ret; +} + +int media_bookmark_get_bookmark_count_from_db(filter_h filter, int *bookmark_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + ret = _media_db_get_group_count(filter, MEDIA_GROUP_BOOKMARK, bookmark_count); + + return ret; +} + +int media_bookmark_foreach_bookmark_from_db (filter_h filter, media_bookmark_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_bookmark(NULL, filter, callback, user_data); + + return ret; +} + +int media_bookmark_destroy(media_bookmark_h bookmark) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark; + + if(_bookmark) + { + SAFE_FREE(_bookmark->media_id); + SAFE_FREE(_bookmark->thumbnail); + free(_bookmark); + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} +int media_bookmark_clone(media_bookmark_h *dst, media_bookmark_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if((src != NULL)) + { + media_bookmark_s *_src = (media_bookmark_s*)src; + media_bookmark_s *_dst = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s)); + + if(NULL == _dst) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _dst->bookmark_id = _src->bookmark_id; + + if(STRING_VALID(_src->media_id)) + { + _dst->media_id = (char*)strdup(_src->media_id); + if(_dst->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_bookmark_destroy((media_bookmark_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->marked_time = _src->marked_time; + + if(STRING_VALID(_src->thumbnail)) + { + _dst->thumbnail = (char*)strdup(_src->thumbnail); + if(_dst->thumbnail == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_bookmark_destroy((media_bookmark_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + *dst = (media_bookmark_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_bookmark_get_bookmark_id(media_bookmark_h bookmark, int *bookmark_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark; + + if(_bookmark) + { + *bookmark_id = _bookmark->bookmark_id; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_bookmark_get_media_id(media_bookmark_h bookmark, char **media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark; + + if(_bookmark) + { + if(STRING_VALID(_bookmark->media_id)) + { + *media_id = strdup(_bookmark->media_id); + if(*media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *media_id = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_bookmark_get_marked_time(media_bookmark_h bookmark, time_t* marked_time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark; + + if(_bookmark) + { + *marked_time = _bookmark->marked_time; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_bookmark_get_thumbnail_path(media_bookmark_h bookmark, char **thumbnail) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_bookmark_s *_bookmark = (media_bookmark_s*)bookmark; + + if(_bookmark) + { + if(STRING_VALID(_bookmark->thumbnail)) + { + *thumbnail = strdup(_bookmark->thumbnail); + if(*thumbnail == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *thumbnail = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} diff --git a/src/media_content.c b/src/media_content.c index c9c6109..4935015 100644..100755 --- a/src/media_content.c +++ b/src/media_content.c @@ -1,207 +1,591 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <media_content.h>
-#include <media_info_private.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <audio-svc-types.h>
-#include <visual-svc-types.h>
-#include <visual-svc.h>
-
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-static MediaSvcHandle* db_handle = NULL;
-static int ref_count = 0;
-
-int media_content_connect()
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if(ref_count == 0)
- {
- if(db_handle == NULL)
- {
- ret = media_svc_connect(&db_handle);
- }
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
-
- ref_count++;
-
- return ret;
-}
-
-
-int media_content_disconnect()
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if(ref_count > 0)
- {
- ref_count--;
- }
- else
- {
- LOGE("[%s]DB_FAILED(0x%08x) database is not connected", __FUNCTION__, MEDIA_CONTENT_ERROR_DB_FAILED);
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
- if(ref_count == 0)
- {
- if(db_handle != NULL)
- {
- ret = media_svc_disconnect(db_handle);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- if( ret == MEDIA_CONTENT_ERROR_NONE)
- {
- db_handle = NULL;
- }
- }
-
- }
-
- return ret;
-}
-
-MediaSvcHandle* _content_get_db_handle()
-{
- return db_handle;
-}
-
-
-int _content_query_prepare(sqlite3_stmt** stmt,char* select_query,char* condition_query, char* search_query,char* limit_query,char* order)
-{
- char* query = NULL;
- int len_query;
-
- if(db_handle == NULL)
- {
- LOGE("[%s]DB_FAILED(0x%08x) database is not connected", __FUNCTION__, MEDIA_CONTENT_ERROR_DB_FAILED);
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
- if((select_query != NULL) && (select_query[0] != 0x00))
- {
- if((search_query == NULL) || search_query[0] == 0x00)
- {
- search_query = " ";
- }
- if((limit_query == NULL) || limit_query[0] == 0x00)
- {
- limit_query = " ";
- }
- if((order == NULL) || order[0] == 0x00)
- {
- order = " ";
- }
- if((condition_query == NULL) ||condition_query[0] == 0x00)
- {
- condition_query = " ";
- }
-
- len_query= strlen(select_query) + 1 + strlen(search_query)+ 1 + strlen(condition_query)+ 1 + strlen(limit_query)+ 1 + strlen(order)+1;
-
- query = (char*)calloc(len_query,sizeof(char));
-
- if(query == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- snprintf(query,len_query,"%s %s %s %s %s",select_query,condition_query,search_query,order,limit_query );
-
- LOGV("[%s]Query : %s",__func__,query);
- if( sqlite3_prepare((sqlite3*)db_handle, query, strlen(query),stmt, NULL) != SQLITE_OK )
- {
- LOGE("[%s]DB_FAILED(0x%08x) fail to sqlite3_prepare(), %s", __FUNCTION__, MEDIA_CONTENT_ERROR_DB_FAILED,sqlite3_errmsg((sqlite3*)db_handle));
- exit(1);
- }
- free(query);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return MEDIA_CONTENT_ERROR_NONE;
-
-}
-
-
-
-int _content_error_capi(media_content_type_e type, int content_error)
-{
- if(type == MEDIA_CONTENT_TYPE)
- {
- if(content_error == MB_SVC_ERROR_NONE)
- return MEDIA_CONTENT_ERROR_NONE;
- else if(content_error == MB_SVC_ERROR_INVALID_PARAMETER || content_error == AUDIO_SVC_ERROR_INVALID_PARAMETER)
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- else if(content_error == MB_SVC_ERROR_DB_INTERNAL || content_error == AUDIO_SVC_ERROR_DB_INTERNAL)
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- else if(content_error == MEDIA_INFO_ERROR_DATABASE_CONNECT || content_error == AUDIO_SVC_ERROR_DB_CONNECT)
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- else if(content_error == MEDIA_INFO_ERROR_DATABASE_DISCONNECT)
- return MEDIA_CONTENT_ERROR_DB_FAILED;
-
- }
- return MEDIA_CONTENT_ERROR_NONE;
-
-}
-
-
-int _content_query_sql(char *query_str)
-{
- int err = MEDIA_CONTENT_ERROR_NONE;
- char *err_msg;
-
- if(db_handle == NULL)
- {
- LOGE("[%s]DB_FAILED(0x%08x) database is not connected",__FUNCTION__, MEDIA_CONTENT_ERROR_DB_FAILED);
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
-
- err = sqlite3_exec(db_handle, query_str, NULL, NULL, &err_msg);
- if (SQLITE_OK != err)
- {
- if (err_msg)
- {
- sqlite3_free(err_msg);
- }
- LOGE("[%s]DB_FAILED(0x%08x) database operation is failed",__FUNCTION__, MEDIA_CONTENT_ERROR_DB_FAILED);
- return MEDIA_CONTENT_ERROR_DB_FAILED;
- }
-
- if (err_msg)
- sqlite3_free(err_msg);
-
- return err;
-}
-
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> +#include <media-util-err.h> + + +static attribute_h g_attr_handle = NULL; +static attribute_h g_alias_attr_handle = NULL; +static MediaSvcHandle *db_handle = NULL; +static int ref_count = 0; + + +static int __media_content_create_attr_handle(void); +static int __media_content_create_alias_attr_handle(void); +static int __media_content_create_attribute_handle(void); +static int __media_content_destroy_attribute_handle(void); + + +static int __media_content_create_attr_handle(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = _media_filter_attribute_create(&g_attr_handle); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Media Info */ + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ID, DB_FIELD_MEDIA_ID); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PATH, DB_FIELD_MEDIA_PATH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DISPLAY_NAME, DB_FIELD_MEDIA_DISPLAY_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TYPE, DB_FIELD_MEDIA_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_MIME_TYPE, DB_FIELD_MEDIA_MIME_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_SIZE, DB_FIELD_MEDIA_SIZE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ADDED_TIME, DB_FIELD_MEDIA_ADDED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_MODIFIED_TIME, DB_FIELD_MEDIA_MODIFIED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_THUMBNAIL_PATH, DB_FIELD_MEDIA_THUMBNAIL_PATH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TITLE, DB_FIELD_MEDIA_TITLE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ALBUM, DB_FIELD_MEDIA_ALBUM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ARTIST, DB_FIELD_MEDIA_ARTIST); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_GENRE, DB_FIELD_MEDIA_GENRE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_COMPOSER, DB_FIELD_MEDIA_COMPOSER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_YEAR, DB_FIELD_MEDIA_YEAR); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_RECORDED_DATE, DB_FIELD_MEDIA_RECORDED_DATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_COPYRIGHT, DB_FIELD_MEDIA_COPYRIGHT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_TRACK_NUM, DB_FIELD_MEDIA_TRACK_NUM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DESCRIPTION, DB_FIELD_MEDIA_DESCRIPTION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_BITRATE, DB_FIELD_MEDIA_BITRATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_SAMPLERATE, DB_FIELD_MEDIA_SAMPLERATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CHANNEL, DB_FIELD_MEDIA_CHANNEL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DURATION, DB_FIELD_MEDIA_DURATION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LONGITUDE, DB_FIELD_MEDIA_LONGITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LATITUDE, DB_FIELD_MEDIA_LATITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ALTITUDE, DB_FIELD_MEDIA_ALTITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_WIDTH, DB_FIELD_MEDIA_WIDTH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_HEIGHT, DB_FIELD_MEDIA_HEIGHT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_DATETAKEN, DB_FIELD_MEDIA_DATETAKEN); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_ORIENTATION, DB_FIELD_MEDIA_ORIENTATION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PLAYED_COUNT, DB_FIELD_MEDIA_PLAYED_COUNT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LAST_PLAYED_TIME, DB_FIELD_MEDIA_LAST_PLAYED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LAST_PLAYED_POSITION, DB_FIELD_MEDIA_LAST_PLAYED_POSITION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_RATING, DB_FIELD_MEDIA_RATING); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_FAVOURITE, DB_FIELD_MEDIA_FAVOURITE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_AUTHOR, DB_FIELD_MEDIA_AUTHOR); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_PROVIDER, DB_FIELD_MEDIA_PROVIDER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CONTENT_NAME, DB_FIELD_MEDIA_CONTENT_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_CATEGORY, DB_FIELD_MEDIA_CATEGORY); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_LOCATION_TAG, DB_FIELD_MEDIA_LOCATION_TAG); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_AGE_RATING, DB_FIELD_MEDIA_AGE_RATING); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_KEYWORD, DB_FIELD_MEDIA_KEYWORD); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_IS_DRM, DB_FIELD_MEDIA_IS_DRM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, MEDIA_STORAGE_TYPE, DB_FIELD_MEDIA_STORAGE_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Playlist*/ + ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_NAME, DB_FIELD_PLAYLIST_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_MEMBER_ORDER, DB_FIELD_PLAYLIST_MEMBER_ORDER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Playlist View */ + ret = _media_filter_attribute_add(g_attr_handle, PLAYLIST_MEDIA_COUNT, DB_FIELD_PLAYLIST_MEDIA_COUNT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Tag*/ + ret = _media_filter_attribute_add(g_attr_handle, TAG_NAME, DB_FIELD_TAG_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Tag View */ + ret = _media_filter_attribute_add(g_attr_handle, TAG_MEDIA_COUNT, DB_FIELD_TAG_MEDIA_COUNT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Bookmark*/ + ret = _media_filter_attribute_add(g_attr_handle, BOOKMARK_MARKED_TIME, DB_FIELD_BOOKMARK_MARKED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + return ret; +} + +static int __media_content_create_alias_attr_handle(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = _media_filter_attribute_create(&g_alias_attr_handle); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Media Info */ + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ID, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ID); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PATH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PATH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DISPLAY_NAME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DISPLAY_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_MIME_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_MIME_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_SIZE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_SIZE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ADDED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ADDED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_MODIFIED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_MODIFIED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_THUMBNAIL_PATH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_THUMBNAIL_PATH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TITLE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TITLE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ALBUM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ALBUM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ARTIST, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ARTIST); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_GENRE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_GENRE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_COMPOSER, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_COMPOSER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_YEAR, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_YEAR); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_RECORDED_DATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_RECORDED_DATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_COPYRIGHT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_COPYRIGHT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_TRACK_NUM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_TRACK_NUM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DESCRIPTION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DESCRIPTION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_BITRATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_BITRATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_SAMPLERATE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_SAMPLERATE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CHANNEL, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CHANNEL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DURATION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DURATION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LONGITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LONGITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LATITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LATITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ALTITUDE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ALTITUDE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_WIDTH, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_WIDTH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_HEIGHT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_HEIGHT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_DATETAKEN, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_DATETAKEN); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_ORIENTATION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_ORIENTATION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PLAYED_COUNT, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PLAYED_COUNT); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LAST_PLAYED_TIME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LAST_PLAYED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LAST_PLAYED_POSITION, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LAST_PLAYED_POSITION); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_RATING, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_RATING); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_FAVOURITE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_FAVOURITE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_AUTHOR, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_AUTHOR); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_PROVIDER, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_PROVIDER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CONTENT_NAME, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CONTENT_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_CATEGORY, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_CATEGORY); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_LOCATION_TAG, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_LOCATION_TAG); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_AGE_RATING, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_AGE_RATING); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_KEYWORD, DB_TABLE_ALIAS_MEDIA"."MEDIA_KEYWORD); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_IS_DRM, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_IS_DRM); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, MEDIA_STORAGE_TYPE, DB_TABLE_ALIAS_MEDIA"."DB_FIELD_MEDIA_STORAGE_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Folder */ + ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_ID, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_ID); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_PATH, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_PATH); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_NAME, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_MODIFIED_TIME, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_MODIFIED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, FOLDER_STORAGE_TYPE, DB_TABLE_ALIAS_FOLDER"."DB_FIELD_FOLDER_STORAGE_TYPE); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Playlist*/ + ret = _media_filter_attribute_add(g_alias_attr_handle, PLAYLIST_NAME, DB_TABLE_ALIAS_PLAYLIST"."DB_FIELD_PLAYLIST_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_add(g_alias_attr_handle, PLAYLIST_MEMBER_ORDER, DB_TABLE_ALIAS_PLAYLIST_MAP"."DB_FIELD_PLAYLIST_MEMBER_ORDER); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Tag*/ + ret = _media_filter_attribute_add(g_alias_attr_handle, TAG_NAME, DB_TABLE_ALIAS_TAG"."DB_FIELD_TAG_NAME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Bookmark*/ + ret = _media_filter_attribute_add(g_alias_attr_handle, BOOKMARK_MARKED_TIME, DB_TABLE_ALIAS_BOOKMARK"."DB_FIELD_BOOKMARK_MARKED_TIME); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + /* Album */ + + return ret; +} + +static int __media_content_create_attribute_handle(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = __media_content_create_attr_handle(); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = __media_content_create_alias_attr_handle(); + + return ret; +} + +static int __media_content_destroy_attribute_handle(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = _media_filter_attribute_destory(g_attr_handle); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = _media_filter_attribute_destory(g_alias_attr_handle); + + return ret; +} + +attribute_h _content_get_attirbute_handle(void) +{ + return g_attr_handle; +} + +attribute_h _content_get_alias_attirbute_handle(void) +{ + return g_alias_attr_handle; +} + +MediaSvcHandle* _content_get_db_handle(void) +{ + return db_handle; +} + +int _content_query_prepare(sqlite3_stmt **stmt, char *select_query, char *condition_query, char *option_query) +{ + int len = 0; + int err = MEDIA_CONTENT_ERROR_NONE; + char query[MAX_QUERY_SIZE]; + memset(query, '\0', sizeof(query)); + + if(db_handle == NULL) + { + media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED); + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + + if(STRING_VALID(select_query)) { + if(!STRING_VALID(condition_query)) { + condition_query = " "; + } + + if(!STRING_VALID(option_query)) { + option_query = " "; + + } + + //query = sqlite3_mprintf("%s %s %s", select_query, condition_query, option_query); + len = snprintf(query, sizeof(query), "%s %s %s", select_query, condition_query, option_query); + if (len > 0) { + query[len] = '\0'; + } else { + media_content_error("snprintf failed"); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_content_debug("Query : [%s]", query); + + err = sqlite3_prepare_v2((sqlite3*)db_handle, query, strlen(query), stmt, NULL); + if(err != SQLITE_OK) + { + media_content_error("DB_FAILED(0x%08x) fail to sqlite3_prepare(), %s", MEDIA_CONTENT_ERROR_DB_FAILED, sqlite3_errmsg((sqlite3*)db_handle)); + + if (err == SQLITE_BUSY) + return MEDIA_CONTENT_ERROR_DB_BUSY; + else + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +int _content_error_capi(int type, int content_error) +{ + if(type == MEDIA_CONTENT_TYPE) + { + if(content_error == MEDIA_INFO_ERROR_NONE) + return MEDIA_CONTENT_ERROR_NONE; + else if(content_error == MEDIA_INFO_ERROR_INVALID_PARAMETER) + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + else if(content_error == MEDIA_INFO_ERROR_DATABASE_INTERNAL) + return MEDIA_CONTENT_ERROR_DB_FAILED; + else if(content_error == MEDIA_INFO_ERROR_DATABASE_CONNECT) + return MEDIA_CONTENT_ERROR_DB_FAILED; + else if(content_error == MEDIA_INFO_ERROR_DATABASE_DISCONNECT) + return MEDIA_CONTENT_ERROR_DB_FAILED; + else if(content_error == MEDIA_INFO_ERROR_DATABASE_NO_RECORD) + return MEDIA_CONTENT_ERROR_DB_FAILED; + } else if(type == MEDIA_REGISTER_TYPE) { + if(content_error == MS_MEDIA_ERR_NONE) + return MEDIA_CONTENT_ERROR_NONE; + else if(content_error == MS_MEDIA_ERR_INVALID_PARAMETER || content_error == MS_MEDIA_ERR_INVALID_PATH) + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + else if(content_error == MS_MEDIA_ERR_INSERT_FAIL || content_error == MS_MEDIA_ERR_DRM_INSERT_FAIL) + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + + media_content_error("content_error : %d [ type :%d ]", content_error, type); + return MEDIA_CONTENT_ERROR_DB_FAILED; +} + +int _content_query_sql(char *query_str) +{ + int err = MEDIA_CONTENT_ERROR_NONE; + char *err_msg; + + if(db_handle == NULL) + { + media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED); + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + + err = sqlite3_exec(db_handle, query_str, NULL, NULL, &err_msg); + if(SQLITE_OK != err) + { + if(err_msg) + { + media_content_error("DB_FAILED : %s", err_msg); + media_content_error("DB_FAILED SQL: %s", query_str); + sqlite3_free(err_msg); + } + + media_content_error("DB_FAILED(0x%08x) database operation is failed", MEDIA_CONTENT_ERROR_DB_FAILED); + + if (err == SQLITE_BUSY) + return MEDIA_CONTENT_ERROR_DB_BUSY; + else + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + else + { + media_content_debug("DB_SUCCESS: %s", query_str); + } + + if(err_msg) + sqlite3_free(err_msg); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int media_content_connect(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(ref_count == 0) + { + if(db_handle == NULL) + { + ret = media_svc_connect(&db_handle); + } + + ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret); + + if(ret == MEDIA_CONTENT_ERROR_NONE) { + ret = __media_content_create_attribute_handle(); + } + } + + ref_count++; + + return ret; +} + +int media_content_disconnect(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(ref_count > 0) + { + ref_count--; + } + else + { + media_content_error("DB_FAILED(0x%08x) database is not connected", MEDIA_CONTENT_ERROR_DB_FAILED); + return MEDIA_CONTENT_ERROR_DB_FAILED; + } + + if(ref_count == 0) + { + if(db_handle != NULL) + { + ret = media_svc_disconnect(db_handle); + ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret); + if(ret == MEDIA_CONTENT_ERROR_NONE) + { + ret = __media_content_destroy_attribute_handle(); + db_handle = NULL; + } + } + } + + return ret; +} diff --git a/src/media_db.c b/src/media_db.c new file mode 100755 index 0000000..a89667a --- /dev/null +++ b/src/media_db.c @@ -0,0 +1,1384 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> + +static char * __media_db_get_group_name(media_group_e group); + +static char * __media_db_get_group_name(media_group_e group) +{ + switch(group) + { + case MEDIA_CONTENT_GROUP_DISPLAY_NAME: + return "file_name"; + case MEDIA_CONTENT_GROUP_TYPE: + return "media_type"; + case MEDIA_CONTENT_GROUP_MIME_TYPE: + return "mime_type"; + case MEDIA_CONTENT_GROUP_SIZE: + return "size"; + case MEDIA_CONTENT_GROUP_ADDED_TIME: + return "added_time"; + case MEDIA_CONTENT_GROUP_MODIFIED_TIME: + return "modified_time"; + case MEDIA_CONTENT_GROUP_TITLE: + return "title"; + case MEDIA_CONTENT_GROUP_ARTIST: + return "artist"; + case MEDIA_CONTENT_GROUP_GENRE: + return "genre"; + case MEDIA_CONTENT_GROUP_COMPOSER: + return "composer"; + case MEDIA_CONTENT_GROUP_YEAR: + return "year"; + case MEDIA_CONTENT_GROUP_RECORDED_DATE: + return "recorded_date"; + case MEDIA_CONTENT_GROUP_COPYRIGHT: + return "copyright"; + case MEDIA_CONTENT_GROUP_TRACK_NUM: + return "track_num"; + case MEDIA_CONTENT_GROUP_DESCRIPTION: + return "description"; + case MEDIA_CONTENT_GROUP_LONGITUDE: + return "longitude"; + case MEDIA_CONTENT_GROUP_LATIITUDE: + return "latitude"; + case MEDIA_CONTENT_GROUP_ALTITUDE: + return "altitude"; + case MEDIA_CONTENT_GROUP_RATING: + return "rating"; + case MEDIA_CONTENT_GROUP_AUTHOR: + return "author"; + case MEDIA_CONTENT_GROUP_PROVIDER: + return "provider"; + case MEDIA_CONTENT_GROUP_CONTENT_NAME: + return "content_name"; + case MEDIA_CONTENT_GROUP_CATEGORY: + return "category"; + case MEDIA_CONTENT_GROUP_LOCATION_TAG: + return "location_tag"; + case MEDIA_CONTENT_GROUP_AGE_RATING: + return "age_rating"; + case MEDIA_CONTENT_GROUP_KEYWORD: + return "keyword"; + default: + return NULL; + } + + return NULL; +} + +int _media_db_get_group_count(filter_h filter, group_list_e group_type, int *group_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + attribute_h attr; + + media_content_debug_func(); + + memset(select_query, 0x00, sizeof(select_query)); + + attr = _content_get_attirbute_handle(); + + switch(group_type) { + case MEDIA_GROUP_NONE: + case MEDIA_GROUP_TAG_BY_MEDIA_ID: + case MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID: + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + break; + case MEDIA_GROUP_ALBUM: + attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_ALBUM_COUNT); + break; + case MEDIA_GROUP_ARTIST: + snprintf(select_query, sizeof(select_query), SELECT_ARTIST_COUNT); + break; + case MEDIA_GROUP_GENRE: + snprintf(select_query, sizeof(select_query), SELECT_GENRE_COUNT); + break; + case MEDIA_GROUP_COMPOSER: + snprintf(select_query, sizeof(select_query), SELECT_COMPOSER_COUNT); + break; + case MEDIA_GROUP_YEAR: + snprintf(select_query, sizeof(select_query), SELECT_YEAR_COUNT); + break; + case MEDIA_GROUP_FOLDER: + attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_FOLDER_COUNT); + break; + case MEDIA_GROUP_PLAYLIST: + //attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_COUNT); + break; + case MEDIA_GROUP_TAG: + //attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_TAG_COUNT); + break; + case MEDIA_GROUP_BOOKMARK: + attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_COUNT); + break; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(STRING_VALID(_filter->condition)) + { + ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(attr, filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *group_count = (int)sqlite3_column_int(stmt, 0); + media_content_debug("group count : [%d]", *group_count); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_media_group_count(media_group_e group, filter_h filter, int *group_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + + media_content_debug_func(); + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_GROUP_COUNT, __media_db_get_group_name(group)); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(STRING_VALID(_filter->condition)) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + if(STRING_VALID(condition_query)) + SAFE_STRLCAT(select_query, condition_query, sizeof(select_query)); + if(STRING_VALID(option_query)) + SAFE_STRLCAT(select_query, option_query, sizeof(select_query)); + + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + } + + SAFE_STRLCAT(select_query, QUERY_KEYWORD_BRACKET, sizeof(select_query)); + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *group_count = (int)sqlite3_column_int(stmt, 0); + media_content_debug("group count : [%d]", *group_count); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_media_group(media_group_e group, filter_h filter, media_group_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + char *name = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_GROUP_LIST, __media_db_get_group_name(group)); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + { + name = strdup((const char *)sqlite3_column_text(stmt, 0)); + media_content_debug("group name : [%s]", name); + } + + if(callback(name, user_data) == false) + { + SAFE_FREE(name); + break; + } + + SAFE_FREE(name); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_album(filter_h filter, media_album_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_ALBUM_LIST); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_album_s *album = (media_album_s*)calloc(1, sizeof(media_album_s)); + + if(album == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + album->album_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + album->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + album->artist = strdup((const char *)sqlite3_column_text(stmt, 2)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3))) + album->album_art_path = strdup((const char *)sqlite3_column_text(stmt, 3)); + + if(callback((media_album_h)album, user_data) == false) + { + media_album_destroy((media_album_h)album); + break; + } + + media_album_destroy((media_album_h)album); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_folder(filter_h filter, media_folder_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_FOLDER_LIST); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s)); + + if(_folder == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2)); + + _folder->storage_type = (int)sqlite3_column_int(stmt,3); + + _folder->modified_time = (int)sqlite3_column_int(stmt,4); + + if(callback((media_folder_h)_folder, user_data) == false) + { + media_folder_destroy((media_folder_h) _folder); + break; + } + + media_folder_destroy((media_folder_h) _folder); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_playlist(filter_h filter, media_playlist_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_LIST); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + //ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + //ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query); + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s)); + + if(_playlist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _playlist->playlist_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(callback((media_playlist_h)_playlist, user_data) == false) + { + media_playlist_destroy((media_playlist_h)_playlist); + break; + } + media_playlist_destroy((media_playlist_h)_playlist); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_playlist_item(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_ITEM_ID_FROM_PLAYLIST_VIEW, playlist_id); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + //ret = _media_filter_attribute_generate(_content_get_alias_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + //ret = _media_filter_attribute_option_generate(_content_get_alias_attirbute_handle(), filter, &option_query); + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + int playlist_member_id = 0; + char media_uuid[MEDIA_CONTENT_UUID_SIZE+1]; + media_info_h media = NULL; + memset(media_uuid, 0x00, sizeof(media_uuid)); + + playlist_member_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + strncpy(media_uuid, (const char *)sqlite3_column_text(stmt, 1), sizeof(media_uuid)); + + ret = media_info_get_media_from_db(media_uuid, &media); + + if(callback(playlist_member_id, media, user_data) == false) + { + media_info_destroy(media); + break; + } + media_info_destroy(media); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +//same as _media_db_get_playlist +int _media_db_get_tag(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + attribute_h attr; + + memset(select_query, 0x00, sizeof(select_query)); + + if(!STRING_VALID(media_id)) + { + //attr = _content_get_alias_attirbute_handle(); + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_TAG_LIST); + } + else + { + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_TAG_LIST_BY_MEDIA_ID, media_id); + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(attr, filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s)); + + if(_tag == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _tag->tag_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(callback((media_tag_h)_tag, user_data) == false) + { + media_tag_destroy((media_tag_h)_tag); + break; + } + media_tag_destroy((media_tag_h)_tag); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_bookmark(const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + attribute_h attr; + + memset(select_query, 0x00, sizeof(select_query)); + + if(!STRING_VALID(media_id)) + { + attr = _content_get_alias_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST); + } + else + { + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_BOOKMARK_LIST_BY_MEDIA_ID_USUAL, media_id); + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(attr, filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_bookmark_s *bookmark = (media_bookmark_s*)calloc(1, sizeof(media_bookmark_s)); + + if(bookmark == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + bookmark->bookmark_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + bookmark->media_id = strdup((const char *)sqlite3_column_text(stmt, 1)); + + bookmark->marked_time = (int)sqlite3_column_int(stmt, 2); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3))) + bookmark->thumbnail = strdup((const char *)sqlite3_column_text(stmt, 3)); + + if(callback((media_bookmark_h)bookmark, user_data) == false) + { + media_bookmark_destroy((media_bookmark_h)bookmark); + break; + } + + media_bookmark_destroy((media_bookmark_h)bookmark); + } + + SQLITE3_FINALIZE(stmt); + + return ret; + +} + +int _media_db_get_group(filter_h filter, media_group_cb callback, void *user_data, group_list_e group_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + char *name = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + if(group_type == MEDIA_GROUP_ARTIST) + { + snprintf(select_query, sizeof(select_query), SELECT_ARTIST_LIST); + } + else if(group_type == MEDIA_GROUP_GENRE) + { + snprintf(select_query, sizeof(select_query), SELECT_GENRE_LIST); + } + else if(group_type == MEDIA_GROUP_COMPOSER) + { + snprintf(select_query, sizeof(select_query), SELECT_COMPOSER_LIST); + } + else if(group_type == MEDIA_GROUP_YEAR) + { + snprintf(select_query, sizeof(select_query), SELECT_YEAR_LIST); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + { + name = strdup((const char *)sqlite3_column_text(stmt, 0)); + media_content_debug("group name : [%s]", name); + } + + if(callback(name, user_data) == false) + { + SAFE_FREE(name); + break; + } + + SAFE_FREE(name); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_group_item_count_by_id(int group_id, filter_h filter, group_list_e group_type, int *item_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + attribute_h attr = NULL; + + media_content_debug_func(); + + memset(select_query, 0x00, sizeof(select_query)); + + if(group_type == MEDIA_GROUP_ALBUM) + { + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_ALBUM, group_id); + } + else if(group_type == MEDIA_GROUP_PLAYLIST) + { + //attr = _content_get_alias_attirbute_handle(); + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_PLAYLIST, group_id); + } + else if(group_type == MEDIA_GROUP_TAG) + { + attr = _content_get_attirbute_handle(); + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_COUNT_FROM_TAG, group_id); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(attr, _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(attr, filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + if((group_type == MEDIA_GROUP_PLAYLIST) || (group_type == MEDIA_GROUP_TAG)) + { + strncat(select_query, QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE)); + + if(STRING_VALID(condition_query)) + strncat(select_query, condition_query, strlen(condition_query)); + if(STRING_VALID(option_query)) + strncat(select_query, option_query, strlen(option_query)); + + strncat(select_query, QUERY_KEYWORD_BRACKET, strlen(QUERY_KEYWORD_BRACKET)); + + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *item_count = (int)sqlite3_column_int(stmt, 0); + media_content_debug("group item count : [%d]", *item_count); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_group_item_count(const char *group_name, filter_h filter, group_list_e group_type, int *item_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + char complete_select_query[DEFAULT_QUERY_SIZE]; + char *select_query = NULL; + char *condition_query = NULL; + char *option_query = NULL; + + media_content_debug_func(); + + if(group_type == MEDIA_GROUP_NONE) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_MEDIA); + } + else if(group_type == MEDIA_GROUP_ARTIST) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_ARTIST, group_name); + } + else if(group_type == MEDIA_GROUP_GENRE) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_GENRE, group_name); + } + else if(group_type == MEDIA_GROUP_COMPOSER) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_COMPOSER, group_name); + } + else if(group_type == MEDIA_GROUP_YEAR) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_YEAR, group_name); + } + else if(group_type == MEDIA_GROUP_FOLDER) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_FOLDER, group_name); + } + else if(group_type == MEDIA_GROUP_TAG_BY_MEDIA_ID) + { + select_query = sqlite3_mprintf(SELECT_TAG_COUNT_BY_MEDIA_ID, group_name); + } + else if(group_type == MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID) + { + select_query = sqlite3_mprintf(SELECT_BOOKMARK_COUNT_BY_MEDIA_ID, group_name); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + + if(STRING_VALID(condition_query)) + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND); + } + else + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + } else { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + + if(group_type == MEDIA_GROUP_NONE) + { + SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_SPACE, sizeof(complete_select_query)); + if(STRING_VALID(condition_query)) + SAFE_STRLCAT(complete_select_query, condition_query, sizeof(complete_select_query)); + if(STRING_VALID(option_query)) + SAFE_STRLCAT(complete_select_query, option_query, sizeof(complete_select_query)); + + SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query)); + + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + } + + ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query); + sqlite3_free(select_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *item_count = (int)sqlite3_column_int(stmt, 0); + media_content_debug("group item count : [%d]", *item_count); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_group_item_by_id(int group_id, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + memset(select_query, 0x00, sizeof(select_query)); + + if(group_type == MEDIA_GROUP_ALBUM) + { + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_ALBUM, group_id); + } + else if(group_type == MEDIA_GROUP_PLAYLIST) + { + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_PLAYLIST, group_id); + } + else if(group_type == MEDIA_GROUP_TAG) + { + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_TAG, group_id); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(STRING_VALID(condition_query)) + { + SAFE_STRLCAT(select_query, QUERY_KEYWORD_SPACE, sizeof(select_query)); + SAFE_STRLCAT(select_query, QUERY_KEYWORD_AND, sizeof(select_query)); + } + } + + ret = _content_query_prepare(&stmt, select_query, condition_query, option_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s)); + if(item == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _media_info_item_get_detail(stmt, (media_info_h)item); + + if(callback((media_info_h)item, user_data) == false) + { + media_info_destroy((media_info_h)item); + break; + } + + media_info_destroy((media_info_h)item); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_group_item(const char *group_name, filter_h filter, media_info_cb callback, void *user_data, group_list_e group_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char complete_select_query[DEFAULT_QUERY_SIZE]; + char *select_query = NULL; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + if(group_type == MEDIA_GROUP_NONE) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_ITEM); + } + else if(group_type == MEDIA_GROUP_ARTIST) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_ARTIST, group_name); + } + else if(group_type == MEDIA_GROUP_GENRE) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_GENRE, group_name); + } + else if(group_type == MEDIA_GROUP_COMPOSER) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_COMPOSER, group_name); + } + else if(group_type == MEDIA_GROUP_YEAR) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_YEAR, group_name); + } + else if(group_type == MEDIA_GROUP_FOLDER) + { + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_FOLDER, group_name); + } + else if(group_type == MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID) + { + select_query = sqlite3_mprintf(SELECT_BOOKMARK_LIST_BY_MEDIA_ID, group_name); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + + if(STRING_VALID(condition_query)) + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND); + } + else + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + } else { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + + ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query); + sqlite3_free(select_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s)); + if(item == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _media_info_item_get_detail(stmt, (media_info_h)item); + + if(callback((media_info_h)item, user_data) == false) + { + media_info_destroy((media_info_h)item); + break; + } + + media_info_destroy((media_info_h)item); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_media_group_item_count(const char *group_name, media_group_e group, filter_h filter, int *item_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + char complete_select_query[DEFAULT_QUERY_SIZE]; + char *select_query = NULL; + char *condition_query = NULL; + char *option_query = NULL; + + media_content_debug_func(); + + if(group_name != NULL) + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_GROUP, __media_db_get_group_name(group), group_name); + else + select_query = sqlite3_mprintf(SELECT_MEDIA_COUNT_FROM_GROUP_NULL, __media_db_get_group_name(group)); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + + if(STRING_VALID(condition_query)) + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND); + } + else + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + } else { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + + SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_SPACE, sizeof(complete_select_query)); + if(STRING_VALID(condition_query)) + SAFE_STRLCAT(complete_select_query, condition_query, sizeof(complete_select_query)); + if(STRING_VALID(option_query)) + SAFE_STRLCAT(complete_select_query, option_query, sizeof(complete_select_query)); + + SAFE_STRLCAT(complete_select_query, QUERY_KEYWORD_BRACKET, sizeof(complete_select_query)); + + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + + ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query); + sqlite3_free(select_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *item_count = (int)sqlite3_column_int(stmt, 0); + media_content_debug("group item count : [%d]", *item_count); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int _media_db_get_media_group_item(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char complete_select_query[DEFAULT_QUERY_SIZE]; + char *select_query = NULL; + char *condition_query = NULL; + char *option_query = NULL; + sqlite3_stmt *stmt = NULL; + filter_s *_filter = NULL; + + media_content_debug_func(); + + if(group_name != NULL) + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_GROUP, __media_db_get_group_name(group), group_name); + else + select_query = sqlite3_mprintf(SELECT_MEDIA_FROM_GROUP_NULL, __media_db_get_group_name(group)); + + if(filter != NULL) + { + _filter = (filter_s*)filter; + + if(_filter->condition) + { + ret = _media_filter_attribute_generate(_content_get_attirbute_handle(), _filter->condition, _filter->condition_collate_type, &condition_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + } + + ret = _media_filter_attribute_option_generate(_content_get_attirbute_handle(), filter, &option_query); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + sqlite3_free(select_query); + return ret; + } + + if(STRING_VALID(condition_query)) + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s %s", select_query, QUERY_KEYWORD_AND); + } + else + { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + } else { + snprintf(complete_select_query, sizeof(complete_select_query), "%s", select_query); + } + + ret = _content_query_prepare(&stmt, complete_select_query, condition_query, option_query); + sqlite3_free(select_query); + SAFE_FREE(condition_query); + SAFE_FREE(option_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_info_s *item = (media_info_s*)calloc(1, sizeof(media_info_s)); + if(item == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _media_info_item_get_detail(stmt, (media_info_h)item); + + if(callback((media_info_h)item, user_data) == false) + { + media_info_destroy((media_info_h)item); + break; + } + + media_info_destroy((media_info_h)item); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} diff --git a/src/media_filter.c b/src/media_filter.c index e975741..4c198f0 100644..100755 --- a/src/media_filter.c +++ b/src/media_filter.c @@ -1,1135 +1,1146 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <media_content.h>
-#include <media_info_private.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <audio-svc-types.h>
-#include <visual-svc-types.h>
-#include <visual-svc.h>
-#include <media-svc.h>
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-
-int media_info_filter_create(media_info_filter_h* filter)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if(filter == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- media_info_filter_s* _filter = (media_info_filter_s*)calloc(1, sizeof(media_info_filter_s));
-
- if(_filter == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY ;
- }
- else {
- _filter->media_type = MEDIA_CONTENT_TYPE_ALL;
- _filter->offset = -1;
- _filter->count = -1;
- _filter->order = MEDIA_CONTENT_SORT_NONE;
- _filter->search_type = MEDIA_INFO_SEARCH_NONE;
- _filter->keyword = NULL;
-
- *filter = (media_info_filter_h)_filter;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- return ret;
-
-}
-
-
-
-int media_info_filter_destroy(media_info_filter_h filter)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- if(_filter->keyword)
- {
- free(_filter->keyword);
- }
- free(_filter);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int media_info_filter_set_offset(media_info_filter_h filter, int offset, int count)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- _filter->offset = offset;
- _filter->count = count;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_info_filter_set_search_keyword(media_info_filter_h filter,media_info_search_type_e search_type,const char *search_keyword)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- free(_filter->keyword);
- _filter->keyword = NULL;
- }
-
- if(search_type == MEDIA_INFO_SEARCH_BY_DISPLAY_NAME)
- {
- if((search_keyword != NULL) && (strlen(search_keyword) > 0))
- {
- _filter->search_type = search_type;
- _filter->keyword = strdup(search_keyword);
- if(_filter->keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else if(search_type == MEDIA_INFO_SEARCH_NONE)
- {
- _filter->search_type = search_type;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_info_filter_set_order(media_info_filter_h filter, media_content_order_e order)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- _filter->order = order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int media_info_filter_set_media_type(media_info_filter_h filter,int media_type)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- if( !(media_type & MEDIA_CONTENT_TYPE_ALL))
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- _filter->media_type = media_type;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_info_filter_get_offset(media_info_filter_h filter, int* offset, int* count)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
-
- *offset = _filter->offset;
- *count = _filter->count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_info_filter_get_search_keyword(media_info_filter_h filter,media_info_search_type_e* search_type, char **search_keyword)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter && (search_type != NULL))
- {
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- *search_keyword = strdup(_filter->keyword);
- if(*search_keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- *search_type = _filter->search_type;
- }
- else
- {
- *search_type = _filter->search_type;
- *search_keyword = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_info_filter_get_order(media_info_filter_h filter, media_content_order_e* order)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- *order = _filter->order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int media_info_filter_get_media_type(media_info_filter_h filter,int* media_type)
-{
- int ret;
- media_info_filter_s* _filter = (media_info_filter_s*)filter;
- if(_filter)
- {
- *media_type = _filter->media_type;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_folder_filter_create(media_folder_filter_h* filter)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- if(filter == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- media_folder_filter_s* _filter = (media_folder_filter_s*)calloc(1, sizeof(media_folder_filter_s));
-
- if(_filter == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY ;
- }
- else
- {
-
- _filter->offset = -1;
- _filter->count = -1;
- _filter->order = MEDIA_CONTENT_SORT_NONE;;
- _filter->search_type = MEDIA_FOLDER_SEARCH_NONE;
- _filter->keyword = NULL;
-
- *filter = (media_folder_filter_h)_filter;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
-
- return ret;
-
-}
-
-int media_folder_filter_destroy(media_folder_filter_h filter)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
- if(_filter->keyword)
- {
- free(_filter->keyword);
- }
- free(_filter);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-
-int media_folder_filter_set_offset(media_folder_filter_h filter, int offset, int count)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
- _filter->offset = offset;
- _filter->count = count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_folder_filter_set_search_keyword(media_folder_filter_h filter,media_folder_search_type_e search_type,const char *search_keyword)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
-
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- free(_filter->keyword);
- _filter->keyword = NULL;
- }
-
- if(search_type == MEDIA_FOLDER_SEARCH_BY_FOLDER_NAME)
- {
- if((search_keyword != NULL) && (strlen(search_keyword) > 0))
- {
- _filter->search_type = search_type;
- _filter->keyword = strdup(search_keyword);
- if(_filter->keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else if(search_type == MEDIA_FOLDER_SEARCH_NONE)
- {
- _filter->search_type = search_type;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_folder_filter_set_order(media_folder_filter_h filter, media_content_order_e order)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
- _filter->order = order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-//-----------------------------------------
-int media_folder_filter_get_offset(media_folder_filter_h filter, int* offset, int* count)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
- *offset = _filter->offset;
- *count = _filter->count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_folder_filter_get_search_keyword(media_folder_filter_h filter,media_folder_search_type_e* search_type, char **search_keyword)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter && (search_type != NULL))
- {
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- *search_keyword = strdup(_filter->keyword);
- if(*search_keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- *search_type =_filter->search_type;
- }
- else
- {
- *search_type = _filter->search_type;
- *search_keyword = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_folder_filter_get_order(media_folder_filter_h filter, media_content_order_e* order)
-{
- int ret;
- media_folder_filter_s* _filter = (media_folder_filter_s*)filter;
- if(_filter)
- {
- *order = _filter->order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_tag_filter_create( media_tag_filter_h* filter)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- if(filter == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- media_tag_filter_s* _filter = (media_tag_filter_s*)calloc(1, sizeof(media_tag_filter_s));
-
- if(_filter == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY ;
- }
- else
- {
- _filter->offset = -1;
- _filter->count = -1;
- _filter->order = MEDIA_CONTENT_SORT_NONE;
- _filter->search_type = MEDIA_INFO_SEARCH_NONE;
- _filter->keyword = NULL;
-
- *filter = (media_tag_filter_h)_filter;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
-
- return ret;
-
-}
-
-int media_tag_filter_destroy(media_tag_filter_h filter)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
- if(_filter->keyword)
- {
- free(_filter->keyword);
- }
- free(_filter);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-
-
-int media_tag_filter_set_offset(media_tag_filter_h filter, int offset, int count)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
- _filter->offset = offset;
- _filter->count = count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_tag_filter_set_search_keyword(media_tag_filter_h filter,media_tag_search_type_e search_type,const char *search_keyword)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
-
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- free(_filter->keyword);
- _filter->keyword = NULL;
- }
-
- if(search_type == MEDIA_TAG_SEARCH_BY_TAG_NAME)
- {
- if((search_keyword != NULL) && (strlen(search_keyword) > 0))
- {
- _filter->search_type = search_type;
- _filter->keyword = strdup(search_keyword);
- if(_filter->keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else if(search_type == MEDIA_TAG_SEARCH_NONE)
- {
- _filter->search_type = search_type;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_tag_filter_set_order(media_tag_filter_h filter, media_content_order_e order)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
- _filter->order = order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_tag_filter_get_offset(media_tag_filter_h filter, int* offset, int* count)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
- *offset = _filter->offset;
- *count = _filter->count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_tag_filter_get_search_keyword(media_tag_filter_h filter,media_tag_search_type_e *search_type, char **search_keyword)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter && (search_type != NULL))
- {
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- *search_keyword = strdup(_filter->keyword);
- if(*search_keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- *search_type = _filter->search_type;
- }
- else
- {
- *search_type = _filter->search_type;
- *search_keyword = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_tag_filter_get_order(media_tag_filter_h filter, media_content_order_e* order)
-{
- int ret;
- media_tag_filter_s* _filter = (media_tag_filter_s*)filter;
- if(_filter)
- {
- *order = _filter->order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_audio_filter_create(media_audio_filter_h* filter)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- if(filter == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- media_audio_filter_s* _filter = (media_audio_filter_s*)calloc(1, sizeof(media_audio_filter_s));
-
- if(_filter == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY ;
- }
- else
- {
- _filter->offset = -1;
- _filter->count = -1;
- _filter->order = MEDIA_CONTENT_SORT_NONE;
- _filter->search_type = MEDIA_AUDIO_SEARCH_NONE;
- _filter->keyword = NULL;
-
- *filter = (media_audio_filter_h)_filter;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
-
- return ret;
-
-}
-
-
-int media_audio_filter_destroy(media_audio_filter_h filter)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
- if(_filter->keyword)
- {
- free(_filter->keyword);
- }
- free(_filter);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_audio_filter_set_offset(media_audio_filter_h filter, int offset, int count)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
- _filter->offset = offset;
- _filter->count = count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_audio_filter_set_search_keyword(media_audio_filter_h filter,media_audio_search_type_e search_type,const char *search_keyword)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
-
-
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- free(_filter->keyword);
- _filter->keyword = NULL;
- }
-
- if((search_type == MEDIA_AUDIO_SEARCH_BY_PLAYLIST) ||
- (search_type == MEDIA_AUDIO_SEARCH_BY_ARTIST) ||
- (search_type == MEDIA_AUDIO_SEARCH_BY_GENRE) ||
- (search_type == MEDIA_AUDIO_SEARCH_BY_ALBUM) ||
- (search_type == MEDIA_AUDIO_SEARCH_BY_AUTHOR) ||
- (search_type == MEDIA_AUDIO_SEARCH_NONE) )
- {
- if((search_keyword != NULL) && (strlen(search_keyword) > 0))
- {
- _filter->search_type = search_type;
- _filter->keyword = strdup(search_keyword);
- if(_filter->keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else if(search_type == MEDIA_AUDIO_SEARCH_NONE)
- {
- _filter->search_type = search_type;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_audio_filter_set_order(media_audio_filter_h filter, media_content_order_e order)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
- _filter->order = order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int media_audio_filter_get_offset(media_audio_filter_h filter, int* offset, int* count)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
- *offset = _filter->offset;
- *count = _filter->count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int media_audio_filter_get_search_keyword(media_audio_filter_h filter,media_audio_search_type_e* search_type,char **keyword)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter && (search_type != NULL))
- {
- if((_filter->keyword != NULL) && (strlen(_filter->keyword) > 0))
- {
- *keyword = strdup(_filter->keyword);
- if(*keyword == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- *search_type = _filter->search_type;
- }
- else
- {
- *search_type = _filter->search_type;
- *keyword = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_audio_filter_get_order(media_audio_filter_h filter, media_content_order_e* order)
-{
- int ret;
- media_audio_filter_s* _filter = (media_audio_filter_s*)filter;
- if(_filter)
- {
- *order = _filter->order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int video_bookmark_filter_create(video_bookmark_filter_h* filter)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- if(filter == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)calloc(1, sizeof(video_bookmark_filter_s));
-
- if(_filter == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY ;
- }
- else
- {
-
- _filter->offset = -1;
- _filter->count = -1;
- _filter->order = MEDIA_CONTENT_SORT_NONE;
-
- *filter = (video_bookmark_filter_h)_filter;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
-
- return ret;
-
-}
-
-
-int video_bookmark_filter_destroy(video_bookmark_filter_h filter)
-{
- int ret;
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)filter;
- if(_filter)
- {
- free(_filter);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-
-int video_bookmark_filter_set_offset(video_bookmark_filter_h filter, int offset, int count)
-{
- int ret;
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)filter;
- if(_filter)
- {
- _filter->offset = offset;
- _filter->count = count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int video_bookmark_filter_set_order(video_bookmark_filter_h filter, media_content_order_e order)
-{
- int ret;
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)filter;
- if(_filter)
- {
- _filter->order = order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int video_bookmark_filter_get_offset(video_bookmark_filter_h filter, int* offset, int* count)
-{
- int ret;
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)filter;
- if(_filter)
- {
- *offset = _filter->offset;
- *count = _filter->count;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
-int video_bookmark_filter_get_order(video_bookmark_filter_h filter, media_content_order_e* order)
-{
- int ret;
- video_bookmark_filter_s* _filter = (video_bookmark_filter_s*)filter;
- if(_filter)
- {
- *order = _filter->order;
-
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> +#include <media-svc.h> + +static char *media_token[] = +{ + " ", + "\"", + "'", + "(", + ")", + "=", + "<=", + "<", + ">=", + ">", +}; + + +typedef struct _token_t +{ + int type; + char *str; +}token_t; + + +#define MAX_LEFT_VALUE 512 +#define SPACE_LEN 1 +#define SPACE " " +#define UNKNOWN_TYPE 1000 +#define STRING_TYPE 100 + +static char *__get_order_str(media_content_order_e order_enum); +static char *__get_collate_str(media_content_collation_e collate_type); +static void __filter_attribute_free_value(gpointer key, gpointer value, gpointer user_data); +static char *__media_filter_replace_attr(attribute_h attr, char *name); +static int __tokenize_operator(token_t *token, const char *str, int op_type); +static int __tokenize(GList **token_list, const char *str); + +static char *__get_order_str(media_content_order_e order_enum) +{ + switch(order_enum) { + case MEDIA_CONTENT_ORDER_ASC: + return "ASC"; + case MEDIA_CONTENT_ORDER_DESC: + return "DESC"; + default: + return " "; + } +} + +static char *__get_collate_str(media_content_collation_e collate_type) +{ + switch(collate_type) { + case MEDIA_CONTENT_COLLATE_NOCASE: + return "NOCASE"; + case MEDIA_CONTENT_COLLATE_RTRIM: + return "RTRIM"; + default: return " "; + } +} + +static void __filter_attribute_free_value(gpointer key, gpointer value, gpointer user_data) +{ + SAFE_FREE(key); + SAFE_FREE(value); +} + +static char *__media_filter_replace_attr(attribute_h attr, char *name) +{ + char *key_temp; + char *generated_value; + attribute_s *_attr = (attribute_s *)attr; + + if(!g_hash_table_lookup_extended(_attr->attr_map, + name, + (gpointer)&key_temp, (gpointer)&generated_value)) + { + //can't find the value + //media_content_error("NOT_FOUND_VALUE(%s)", name); + return NULL; + } + + if(STRING_VALID(generated_value)) + { + return strdup(generated_value); + } + + media_content_error("__media_filter_replace_attr fail"); + + return NULL; +} + +static int __tokenize_operator(token_t *token, const char *str, int op_type) +{ + int ret = 0; + const char *tmp = str; + + if(token != NULL && STRING_VALID(tmp)) + { + token->type = op_type; + int token_size = strlen(media_token[op_type]); + token->str = (char*)calloc(token_size+1, sizeof(char)); + strncpy(token->str, tmp, token_size); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + ret = token_size; + } + else + { + ret = -1; + } + + return ret; +} + +static int __tokenize_string(token_t *token, const char *str, int size) +{ + int ret = size; + const char *tmp = str; + + if(token != NULL && STRING_VALID(tmp) && size > 0) + { + token->str = (char*)calloc(size+1, sizeof(char)); + token->type = UNKNOWN_TYPE; + strncpy(token->str, tmp, size); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + } + else + { + ret = -1; + } + + return ret; +} + +static int __tokenize_attribute(GList **token_list, const char *str) +{ + int ret = 0; + int idx = 0; + + if(!STRING_VALID(str)) { + media_content_error("Parameter string in invalid"); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + const char *tmp = str; + const char *dst_ptr = str + strlen(str); + + for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) + { + //media_content_debug("[%d] '%c'", idx, tmp[idx]); + if(tmp[idx] == ' ') //" " + { + if(idx == 0) // ignore the space. + { + tmp++; + idx = -1; + continue; + } + + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->type = UNKNOWN_TYPE; + token->str = (char*)calloc(idx+1, sizeof(char)); + strncpy(token->str, tmp, idx); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + *token_list = g_list_append(*token_list, token); + tmp = tmp +idx + strlen(media_token[0]); + idx = -1; + } + else if(tmp[idx] == ',') // " , " + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,3); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + } + } + + if(*tmp) //remained string + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + __tokenize_string(token, tmp, idx); + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +static int __tokenize(GList **token_list, const char *str) +{ + int ret = 0; + int idx = 0; + + if(!STRING_VALID(str)) { + media_content_error("Parameter string in invalid"); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + const char *tmp = str; + const char *dst_ptr = str + strlen(str); + + for (idx = 0; (*(tmp+idx)) && (tmp < dst_ptr); idx++) + { + //media_content_debug("[%d] '%c'", idx, tmp[idx]); + if(tmp[idx] == media_token[0][0]) //" " + { + if(idx == 0) // ignore the space. + { + tmp++; + idx = -1; + continue; + } + + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->type = UNKNOWN_TYPE; + token->str = (char*)calloc(idx+1, sizeof(char)); + strncpy(token->str, tmp, idx); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + *token_list = g_list_append(*token_list, token); + tmp = tmp +idx + strlen(media_token[0]); + idx = -1; + } + else if(tmp[idx] == media_token[1][0]) // " \" " + { + int j; + for(j = idx+1; tmp[j]; j++) //find next quotation + { + if(tmp[j] == media_token[1][0] && tmp[j+1] == media_token[1][0]) + { + j += 2; + continue; + } + if(tmp[j] == media_token[1][0]) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->str = (char*) calloc(j+1+1, sizeof(char)); + token->type = STRING_TYPE; + strncpy(token->str, tmp, j+1); + media_content_debug("type : [%d] str : [%s], j : %d \n", token->type, token->str, j); + *token_list = g_list_append(*token_list, token); + tmp = tmp + strlen(token->str); + idx = -1; + break; + } + } + + if(*tmp != '\0' && tmp[j]=='\0') + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->str = (char*) calloc(j+1,sizeof(char)); + token->type = UNKNOWN_TYPE; + strncpy(token->str, tmp,j); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + *token_list = g_list_append(*token_list, token); + tmp = tmp +strlen(token->str); + idx = -1; + } + } + else if(tmp[idx] == media_token[2][0]) // " \' " + { + int j; + for(j = idx+1; tmp[j]; j++) + { + if(tmp[j] == media_token[2][0] && tmp[j+1] == media_token[2][0]) + { + j += 2; + continue; + } + if(tmp[j] == media_token[2][0]) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->str = (char*) calloc(j+1+1, sizeof(char)); + token->type = STRING_TYPE; + strncpy(token->str, tmp, j+1); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + *token_list = g_list_append(*token_list, token); + tmp = tmp + strlen(token->str); + idx = -1; + break; + } + } + + if(*tmp != '\0' && tmp[j]=='\0') + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + token->str = (char*) calloc(j+1,sizeof(char)); + token->type = UNKNOWN_TYPE; + strncpy(token->str, tmp,j); + media_content_debug("type : [%d] str : [%s] \n", token->type, token->str); + *token_list = g_list_append(*token_list, token); + tmp = tmp + strlen(token->str); + idx = -1; + } + } + else if(tmp[idx] == media_token[3][0]) //"(" + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,3); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[4][0]) //")" + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,4); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[5][0]) //"=" + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,5); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[6][0] && tmp[idx+1] == media_token[6][1]) //"<=", + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,6); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[7][0]) //"<", + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,7); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[8][0] && tmp[idx+1] == media_token[8][1]) //">=", + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,8); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + else if(tmp[idx] == media_token[9][0]) //">", + { + if(idx != 0) + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + ret = __tokenize_string(token, tmp, idx); + if (ret < 0) + { + media_content_error("tokenize error occued"); + return -1; + } + else + { + *token_list = g_list_append(*token_list, token); + tmp = tmp + idx; + } + } + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + int size = __tokenize_operator(token, tmp,9); + + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + tmp += size; + idx = -1; + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + + } + } + + if(*tmp) //remained string + { + token_t *token = (token_t*)calloc(1, sizeof(token_t)); + __tokenize_string(token, tmp, idx); + if(token != NULL && STRING_VALID(token->str)) + { + *token_list = g_list_append(*token_list, token); + } + else + { + media_content_error("tokenize error occued"); + return -1; + } + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +int _media_filter_attribute_create(attribute_h *attr) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(attr == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + attribute_s *_attr = (attribute_s*)calloc(1, sizeof(attribute_s)); + + if(_attr == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + else + { + _attr->attr_map = g_hash_table_new (g_str_hash, g_str_equal); + *attr = (attribute_h)_attr; + } + + return ret; +} + +int _media_filter_attribute_add(attribute_h attr, char *user_attr, char *platform_attr) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *_user = NULL; + char *_platform = NULL; + attribute_s *_attr = (attribute_s*)attr; + + if(_attr != NULL) + { + if(STRING_VALID(user_attr) && STRING_VALID(platform_attr)) + { + _user = strdup(user_attr); + if(_user == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _platform = strdup(platform_attr); + if(_platform == NULL) + { + SAFE_FREE(_user); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + g_hash_table_insert (_attr->attr_map, _user, _platform); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int _media_filter_attribute_remove(attribute_h attr, char *user_attr) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + attribute_s *_attr = (attribute_s*)attr; + + if(attr != NULL) + { + if(STRING_VALID(user_attr)) + { + g_hash_table_remove(_attr->attr_map, user_attr); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int _media_filter_attribute_destory(attribute_h attr) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + attribute_s *_attr = (attribute_s*)attr; + + if(_attr != NULL) + { + if(_attr->attr_map != NULL) + { + g_hash_table_foreach(_attr->attr_map, __filter_attribute_free_value, NULL); + g_hash_table_destroy(_attr->attr_map); + } + + SAFE_FREE(_attr); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int _media_filter_attribute_generate(attribute_h attr, char *condition, media_content_collation_e collate_type, char **generated_condition) +{ + int idx = 0; + GList *token_list = NULL; + int size = 0; + int ret = MEDIA_CONTENT_ERROR_NONE; + int total_str_size = 0; + token_t *token; + + if((condition == NULL) || (generated_condition == NULL)) + { + media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(attr != NULL) + { + if(__tokenize(&token_list, condition) < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + for(idx = 0; idx < g_list_length(token_list); idx++) + { + token = (token_t*)g_list_nth_data(token_list, idx); + + if(token->type == UNKNOWN_TYPE) + { + char *replace_str = __media_filter_replace_attr(attr, token->str); + if(STRING_VALID(replace_str)) + { + SAFE_FREE(token->str); + token->str = replace_str; + } + } + + total_str_size += strlen(token->str)+1; + media_content_debug("[%d][type:%d]:%s\n", idx, token->type, token->str); + } + + //make the statment + size = total_str_size + COLLATE_STR_SIZE + 1; + * generated_condition = (char*)calloc(size, sizeof(char)); + + for(idx = 0; idx < g_list_length(token_list); idx++) + { + token = (token_t*)g_list_nth_data(token_list, idx); + + if((token != NULL) && STRING_VALID(token->str)) + { + SAFE_STRLCAT(*generated_condition, token->str, size); + SAFE_STRLCAT(*generated_condition, SPACE, size); + + SAFE_FREE(token->str); + SAFE_FREE(token); + } + } + + if(collate_type == MEDIA_CONTENT_COLLATE_NOCASE || collate_type == MEDIA_CONTENT_COLLATE_RTRIM) { + SAFE_STRLCAT(*generated_condition, "COLLATE ", size); + SAFE_STRLCAT(*generated_condition, __get_collate_str(collate_type), size); + SAFE_STRLCAT(*generated_condition, SPACE, size); + } + + media_content_debug("statement : %s(%d) (total:%d) \n", *generated_condition, strlen(*generated_condition), total_str_size); + media_content_debug("Condition : %s", *generated_condition); + + //if(*generated_condition != NULL) + // res = 1; + + if(token_list != NULL) + g_list_free(token_list); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int _media_filter_attribute_option_generate(attribute_h attr, filter_h filter, char **generated_option) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = NULL; + char option_query[DEFAULT_QUERY_SIZE] = {0, }; + char condition[DEFAULT_QUERY_SIZE] = {0, }; + int size = 0; + //bool order_by = true; + + media_content_debug_func(); + + if(filter == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(attr == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + _filter = (filter_s*)filter; + + memset(option_query, 0x00, sizeof(option_query)); + + /* Order by*/ + if(STRING_VALID(_filter->order_keyword) && ((_filter->order_type == MEDIA_CONTENT_ORDER_ASC) ||(_filter->order_type == MEDIA_CONTENT_ORDER_DESC))) + { + int idx = 0; + int total_str_size = 0; + GList *token_list = NULL; + token_t *token; + char *attr_str; + + media_content_debug("Tokenize for [%s]", _filter->order_keyword); + if(__tokenize_attribute(&token_list, _filter->order_keyword) < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x):Invalid the condition", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + for(idx = 0; idx < g_list_length(token_list); idx++) + { + token = (token_t*)g_list_nth_data(token_list, idx); + + if(token->type == UNKNOWN_TYPE) + { + char *replace_str = __media_filter_replace_attr(attr, token->str); + if(STRING_VALID(replace_str)) + { + attr_str = (char*)calloc(strlen(replace_str) + COLLATE_STR_SIZE + 1, sizeof(char)); + + if(_filter->order_collate_type == MEDIA_CONTENT_COLLATE_NOCASE || _filter->order_collate_type == MEDIA_CONTENT_COLLATE_RTRIM) { + snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s COLLATE %s %s", replace_str, __get_collate_str(_filter->order_collate_type), __get_order_str(_filter->order_type)); + } else { + snprintf(attr_str, strlen(replace_str) + COLLATE_STR_SIZE + 1, "%s %s", replace_str, __get_order_str(_filter->order_type)); + } + + SAFE_FREE(token->str); + token->str = attr_str; + SAFE_FREE(replace_str); + } + else + { + media_content_error("There is no matched db field for %s", token->str); + } + } + + total_str_size += strlen(token->str) + 1; + media_content_debug("[%d][type:%d]:%s\n", idx, token->type, token->str); + } + + //make the statment + char *generated_condition = NULL; + size = total_str_size + COLLATE_STR_SIZE + 1; + generated_condition = (char*)calloc(size, sizeof(char)); + + for(idx = 0; idx < g_list_length(token_list); idx++) + { + token = (token_t*)g_list_nth_data(token_list, idx); + + if((token != NULL) && STRING_VALID(token->str)) + { + media_content_debug("[%d] %s", idx, token->str); + SAFE_STRLCAT(generated_condition, token->str, size); + SAFE_STRLCAT(generated_condition, SPACE, size); + + SAFE_FREE(token->str); + SAFE_FREE(token); + } + } + + snprintf(condition, sizeof(condition), "ORDER BY %s", generated_condition); + SAFE_STRLCAT(option_query, condition, sizeof(option_query)); + + if(token_list != NULL) + g_list_free(token_list); + } + + /* offset */ + if((_filter->offset >= 0) && (_filter->count >= 0)) + { + SAFE_STRLCAT(option_query, SPACE, sizeof(option_query)); + snprintf(condition, sizeof(condition), "LIMIT %d, %d", _filter->offset, _filter->count); + SAFE_STRLCAT(option_query, condition, sizeof(option_query)); + } + + if(STRING_VALID(option_query)) + { + *generated_option = strdup(option_query); + } + else + { + *generated_option = NULL; + } + + return ret; +} + +int media_filter_create(filter_h *filter) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(filter == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + filter_s *_filter = (filter_s*)calloc(1, sizeof(filter_s)); + + if(_filter == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + ret = MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + else + { + _filter->condition = NULL; + _filter->order_keyword = NULL; + _filter->order_type = -1; + _filter->condition_collate_type = MEDIA_CONTENT_COLLATE_DEFAULT; + _filter->order_collate_type = MEDIA_CONTENT_COLLATE_DEFAULT; + _filter->offset = -1; + _filter->count = -1; + + *filter = (filter_h)_filter; + } + + return ret; +} + +int media_filter_destroy(filter_h filter) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if(_filter) + { + SAFE_FREE(_filter->condition); + SAFE_FREE(_filter->order_keyword); + SAFE_FREE(_filter); + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_set_offset(filter_h filter, int offset, int count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if((_filter != NULL) && (offset >= 0) && (count > 0)) + { + _filter->offset = offset; + _filter->count = count; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_set_condition(filter_h filter, const char *condition, media_content_collation_e collate_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if((_filter != NULL) && STRING_VALID(condition) + && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_RTRIM))) + { + if(STRING_VALID(_filter->condition)) + { + SAFE_FREE(_filter->condition); + } + + _filter->condition = strdup(condition); + if(_filter->condition == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + media_content_debug("Condition string : %s", _filter->condition); + + _filter->condition_collate_type = collate_type; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_set_order(filter_h filter, media_content_order_e order_type, const char *order_keyword, media_content_collation_e collate_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if((_filter != NULL) && STRING_VALID(order_keyword) + && ((order_type == MEDIA_CONTENT_ORDER_ASC) ||(order_type == MEDIA_CONTENT_ORDER_DESC)) + && ((collate_type >= MEDIA_CONTENT_COLLATE_DEFAULT) && (collate_type <= MEDIA_CONTENT_COLLATE_RTRIM))) + { + SAFE_FREE(_filter->order_keyword); + + if(STRING_VALID(order_keyword)) + { + _filter->order_keyword = strdup(order_keyword); + + if(_filter->order_keyword == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + _filter->order_type = order_type; + _filter->order_collate_type = collate_type; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_get_offset(filter_h filter, int *offset, int *count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if(_filter) + { + *offset = _filter->offset; + *count = _filter->count; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_get_condition(filter_h filter, char **condition, media_content_collation_e *collate_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if(_filter) + { + if(STRING_VALID(_filter->condition)) + { + *condition = strdup(_filter->condition); + if(*condition == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *condition = NULL; + } + + *collate_type = _filter->condition_collate_type; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_filter_get_order(filter_h filter, media_content_order_e* order_type, char **order_keyword, media_content_collation_e *collate_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_s *_filter = (filter_s*)filter; + + if(_filter) + { + if(STRING_VALID(_filter->order_keyword)) + { + *order_keyword = strdup(_filter->order_keyword); + if(*order_keyword == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *order_keyword = NULL; + } + + *order_type = _filter->order_type; + *collate_type = _filter->order_collate_type; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} diff --git a/src/media_folder.c b/src/media_folder.c index ab0fa79..e805d76 100644..100755 --- a/src/media_folder.c +++ b/src/media_folder.c @@ -1,589 +1,571 @@ - /*
- * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
- *
- * 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 <media_content.h>
-#include <media_info_private.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <audio-svc-types.h>
-#include <visual-svc-types.h>
-#include <visual-svc.h>
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-
-
-int media_folder_foreach_media_from_db(media_folder_h folder,media_info_filter_h filter,media_info_cb callback, void* user_data)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- char limit_query[MIN_QUERY_SIZE];
- char condition_query[DEFAULT_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char condition_type[MIN_QUERY_SIZE];
- char select_query1[DEFAULT_QUERY_SIZE];
- char order_query[MIN_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
- media_info_filter_s* _filter = NULL;
-
- media_folder_s* _folder = (media_folder_s*)folder;
-
- if(_folder == NULL || callback == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(filter != NULL)
- {
- _filter = (media_info_filter_s*)filter;
-
- if(!(_filter->media_type & (MEDIA_CONTENT_TYPE_IMAGE | MEDIA_CONTENT_TYPE_VIDEO | MEDIA_CONTENT_TYPE_AUDIO)) )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- ret = media_info_filter_create((media_info_filter_h*)&_filter);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- return ret;
- }
-
- if(_filter->media_type == 0)
- {
- _filter->media_type = (MEDIA_CONTENT_TYPE_IMAGE | MEDIA_CONTENT_TYPE_VIDEO | MEDIA_CONTENT_TYPE_AUDIO);
- }
- }
-
- memset(order_query,0x00,sizeof(order_query));
- memset(condition_type,0x00,sizeof(condition_type));
- memset(condition_query,0x00,sizeof(condition_query));
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(select_query1,0x00,sizeof(select_query1));
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_info_filter_s*)filter != _filter)
- media_info_filter_destroy((media_info_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
- if(_filter->media_type & MEDIA_CONTENT_TYPE_IMAGE)
- {
- strncat(condition_type,CONDITION_TYPE_IMAGE,strlen(CONDITION_TYPE_IMAGE));
- }
- if(_filter->media_type & MEDIA_CONTENT_TYPE_VIDEO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
- strncat(condition_type,CONDITION_TYPE_VIDEO,strlen(CONDITION_TYPE_VIDEO));
-
- }
- if(_filter->media_type & MEDIA_CONTENT_TYPE_AUDIO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
-
- strncat(condition_type,CONDITION_TYPE_AUDIO,strlen(CONDITION_TYPE_AUDIO));
- }
-
-
- snprintf(select_query1,sizeof(select_query1),"%s", SELECT_MEDIA_ITEM);
-
-
- snprintf(condition_query,sizeof(condition_query), "%s %s='%s' %s (%s)",
- QUERY_KEYWORD_AND, DB_FIELD_FOLDER_UID,_folder->folder_uid, QUERY_KEYWORD_AND, condition_type);
-
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
- if((media_info_filter_s*)filter != _filter)
- media_info_filter_destroy((media_info_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query1, condition_query,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- return ret;
- }
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item1 = (media_info_s*)calloc(1,sizeof(media_info_s));
- if(item1 == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _content_item_get_detail(stmt,(media_info_h)item1);
- if( callback((media_info_h)item1,user_data) == 0)
- {
- media_info_destroy((media_info_h)item1);
- break;
- }
- media_info_destroy((media_info_h)item1);
-
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-}
-
-int media_folder_foreach_folder_from_db(media_folder_filter_h filter,media_folder_cb callback, void* user_data)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
-
- char order_query[MIN_QUERY_SIZE];
- char limit_query[MIN_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
- char condition_query[DEFAULT_QUERY_SIZE];
-
-
- sqlite3_stmt *stmt = NULL;
- media_folder_filter_s* _filter = NULL;
-
-
- if( callback == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- memset(order_query,0x00,sizeof(order_query));
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(select_query,0x00,sizeof(select_query));
- memset(condition_query,0x00,sizeof(condition_query));
-
-
- if(filter != NULL)
- _filter = (media_folder_filter_s*)filter;
- else
- {
- media_folder_filter_create((media_folder_filter_h*)&_filter);
- }
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_folder_filter_s*)filter != _filter)
- media_folder_filter_destroy((media_folder_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(select_query,sizeof(select_query),"%s",SELECT_ALL_FOLDER);
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
- if((media_folder_filter_s*)filter != _filter)
- media_folder_filter_destroy((media_folder_filter_h)_filter);
-
- if(select_query != NULL)
- {
- ret = _content_query_prepare(&stmt,select_query,condition_query,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- return ret;
- }
- }
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_folder_s* _folder = (media_folder_s*)calloc(1,sizeof(media_folder_s));
-
- if(_folder == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _content_folder_get_detail(stmt,(media_folder_h)_folder);
- if(callback((media_folder_h)_folder,user_data) == false)
- {
- media_folder_destroy((media_folder_h) _folder);
-
- break;
-
- }
-
- media_folder_destroy((media_folder_h) _folder);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-}
-int media_folder_get_media_count_from_db(media_folder_h folder,media_content_type_e type, int* count)
-{
- int _tmp;
-
- int ret= MEDIA_CONTENT_ERROR_NONE;
-
- char condition_query[MIN_QUERY_SIZE];
- char condition_type[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
- sqlite3_stmt *stmt = NULL;
-
- media_folder_s* _folder = (media_folder_s*)folder;
-
- if(_folder == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- memset(condition_type, 0x00,sizeof(condition_type));
- memset(condition_query, 0x00,sizeof(condition_query));
- memset(select_query, 0x00,sizeof(select_query));
-
-
-
- if(type & MEDIA_CONTENT_TYPE_IMAGE)
- {
- strncat(condition_type,CONDITION_TYPE_IMAGE,strlen(CONDITION_TYPE_IMAGE));
- }
- if(type & MEDIA_CONTENT_TYPE_VIDEO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
- strncat(condition_type,CONDITION_TYPE_VIDEO,strlen(CONDITION_TYPE_VIDEO));
-
- }
- if(type & MEDIA_CONTENT_TYPE_AUDIO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
-
- strncat(condition_type,CONDITION_TYPE_AUDIO,strlen(CONDITION_TYPE_AUDIO));
- }
-
- snprintf(condition_query,sizeof(condition_query), "%s %s='%s' %s (%s)",
- QUERY_KEYWORD_AND, DB_FIELD_FOLDER_UID,_folder->folder_uid, QUERY_KEYWORD_AND, condition_type);
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_COUNT_ITEM);
-
-
- _tmp = _content_query_prepare(&stmt,select_query,condition_query,NULL,NULL,NULL);
-
- if(_tmp != MEDIA_CONTENT_ERROR_NONE)
- return _tmp;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- *count = (int)sqlite3_column_int(stmt,0);
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-
-int media_folder_destroy(media_folder_h folder)
-{
- int ret;
- media_folder_s* _folder = (media_folder_s*)folder;
- if(_folder)
- {
- if(_folder->path)
- {
- free(_folder->path);
- }
- if(_folder->name)
- {
- free(_folder->name);
- }
- if(_folder->folder_uid)
- {
- free(_folder->folder_uid);
- }
- free(_folder);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-int media_folder_clone(media_folder_h* dst, media_folder_h src)
-{
- int ret;
- media_folder_s* _src = (media_folder_s*)src;
-
-
- if(_src != NULL)
- {
- media_folder_s* _dst = (media_folder_s*)calloc(1,sizeof(media_folder_s));
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- _dst->folder_uid = strdup(_src->folder_uid);
- if(_dst->folder_uid == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-
- }
- _dst->storage_type = _src->storage_type;
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_folder_destroy((media_folder_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->path != NULL) && (strlen(_src->path) > 0))
- {
- _dst->path = strdup(_src->path);
- if(_dst->path == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_folder_destroy((media_folder_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- *dst = (media_folder_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_folder_get_path(media_folder_h folder, char** path)
-{
- int ret;
- media_folder_s* _folder = (media_folder_s*)folder;
- if(_folder)
- {
- if((_folder->path != NULL) && (strlen(_folder->path) > 0))
- {
- *path = strdup(_folder->path);
- if(*path == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *path = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-int media_folder_get_name(media_folder_h folder, char** name)
-{
- int ret;
- media_folder_s* _folder = (media_folder_s*)folder;
- if(_folder)
- {
- if((_folder->name != NULL) && (strlen(_folder->name) > 0))
- {
- *name = strdup(_folder->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type)
-{
- int ret;
- media_folder_s* _folder = (media_folder_s*)folder;
- if(_folder)
- {
- *storage_type = _folder->storage_type;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_folder_get_date_modified(media_folder_h folder, time_t* time)
-{
- int ret;
- media_folder_s* _folder = (media_folder_s*)folder;
- if(_folder)
- {
- *time = _folder->date_modified;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-void _content_folder_get_detail(sqlite3_stmt* stmt, media_folder_h folder)
-{
- media_folder_s* _folder = (media_folder_s*)folder;
- _folder->folder_uid = strdup((const char *)sqlite3_column_text(stmt, 0));
- _folder->path= strdup((const char *)sqlite3_column_text(stmt, 1));
- _folder->name=strdup((const char *)sqlite3_column_text(stmt, 2));
- _folder->storage_type=(int)sqlite3_column_int(stmt,3);
- _folder->date_modified=(int)sqlite3_column_int(stmt,4);
-}
-
-
+ /* + * Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved + * + * 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 <media_content.h> +#include <media_info_private.h> +#include <media_util_private.h> + +static char *g_src_path = NULL; + +static void __media_folder_get_detail(sqlite3_stmt *stmt, media_folder_h folder); +static int __media_folder_get_folder_info_from_db(const char *path, media_folder_h folder); +static char *__media_folder_get_update_folder_sql(media_folder_h folder); + +static void __media_folder_get_detail(sqlite3_stmt* stmt, media_folder_h folder) +{ + media_folder_s *_folder = (media_folder_s*)folder; + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2)); + + _folder->storage_type = (int)sqlite3_column_int(stmt,3); + + _folder->modified_time = (int)sqlite3_column_int(stmt,4); +} + +static int __media_folder_get_folder_info_from_db(const char *path, media_folder_h folder) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char *select_query = NULL; + media_folder_s *_folder = (media_folder_s*)folder; + + if(_folder == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + select_query = sqlite3_mprintf(SELECT_FOLDER_BY_PATH, path); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + sqlite3_free(select_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + __media_folder_get_detail(stmt, (media_folder_h)_folder); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +static char *__media_folder_get_update_folder_sql(media_folder_h folder) +{ + media_folder_s *_folder = (media_folder_s*)folder; + char *return_sql = NULL; + + return_sql = sqlite3_mprintf("%q='%q', %q='%q', %q=%d ", + DB_FIELD_FOLDER_PATH, _folder->path, + DB_FIELD_FOLDER_NAME, _folder->name, + DB_FIELD_FOLDER_MODIFIED_TIME, _folder->modified_time); + + return return_sql; +} + +int media_folder_insert_to_db(const char *path, media_folder_h *folder) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int storage_type = -1; + + if(!STRING_VALID(path)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s)); + + _folder->path = strdup(path); + _media_util_get_store_type_by_path(path, &storage_type); + _folder->storage_type = storage_type; + + if(_folder->path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + /* New media svc api */ + ret = media_svc_insert_folder(_content_get_db_handle(), _folder->storage_type, _folder->path); + + if(ret == MEDIA_INFO_ERROR_NONE) + { + ret = __media_folder_get_folder_info_from_db(_folder->path, (media_folder_h)_folder); + *folder = (media_folder_h)_folder; + } + + return _content_error_capi(MEDIA_CONTENT_TYPE, ret); +} + +int media_folder_delete_from_db(const char *folder_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + char *query_string = NULL; + + if(!STRING_VALID(folder_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + query_string = sqlite3_mprintf(DELETE_FOLDER_FROM_FOLDER, folder_id); + + ret = _content_query_sql(query_string); + + sqlite3_free(query_string); + + return ret; +} + +int media_folder_get_folder_count_from_db(filter_h filter, int *folder_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(!folder_count) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_content_debug_func(); + + ret = _media_db_get_group_count(filter, MEDIA_GROUP_FOLDER, folder_count); + + return ret; +} + +int media_folder_foreach_folder_from_db(filter_h filter, media_folder_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_folder(filter, callback, user_data); + + return ret; +} + +int media_folder_get_media_count_from_db(const char *folder_id, filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(STRING_VALID(folder_id) && media_count) + { + ret = _media_db_get_group_item_count(folder_id, filter, MEDIA_GROUP_FOLDER, media_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_foreach_media_from_db(const char *folder_id, filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((callback != NULL) && STRING_VALID(folder_id)) + { + ret = _media_db_get_group_item(folder_id, filter, callback, user_data, MEDIA_GROUP_FOLDER); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_destroy(media_folder_h folder) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + if(_folder) + { + SAFE_FREE(_folder->path); + SAFE_FREE(_folder->name); + SAFE_FREE(_folder->folder_id); + SAFE_FREE(_folder); + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} +int media_folder_clone(media_folder_h *dst, media_folder_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_src = (media_folder_s*)src; + + if(_src != NULL) + { + media_folder_s *_dst = (media_folder_s*)calloc(1, sizeof(media_folder_s)); + if(_dst == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->folder_id)) + { + _dst->folder_id = strdup(_src->folder_id); + if(_dst->folder_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->storage_type = _src->storage_type; + + if(STRING_VALID(_src->name)) + { + _dst->name = strdup(_src->name); + if(_dst->name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_folder_destroy((media_folder_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->path)) + { + _dst->path = strdup(_src->path); + if(_dst->path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_folder_destroy((media_folder_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + *dst = (media_folder_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_get_folder_id(media_folder_h folder, char **folder_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + + if(_folder) + { + if(STRING_VALID(_folder->folder_id)) + { + *folder_id = strdup(_folder->folder_id); + if(*folder_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *folder_id = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_get_path(media_folder_h folder, char **path) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + if(_folder) + { + if(STRING_VALID(_folder->path)) + { + *path = strdup(_folder->path); + if(*path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *path = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; + +} + +int media_folder_get_name(media_folder_h folder, char **name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + if(_folder) + { + if(STRING_VALID(_folder->name)) + { + *name = strdup(_folder->name); + if(*name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_get_modified_time(media_folder_h folder, time_t* time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + if(_folder) + { + *time = _folder->modified_time; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_get_storage_type(media_folder_h folder, media_content_storage_e* storage_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + if(_folder) + { + *storage_type = _folder->storage_type; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_get_folder_from_db(const char *folder_id, media_folder_h *folder) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + + if(!STRING_VALID(folder_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_FOLDER_FROM_FOLDER, folder_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_folder_s *_folder = (media_folder_s*)calloc(1, sizeof(media_folder_s)); + + if(_folder == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _folder->folder_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _folder->path = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _folder->name = strdup((const char *)sqlite3_column_text(stmt, 2)); + + *folder = (media_folder_h)_folder; + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_folder_update_to_db(media_folder_h folder) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int len = 0; + media_folder_s *_folder = (media_folder_s*)folder; + + char sql[MAX_QUERY_SIZE]; + memset(sql, '\0', sizeof(sql)); + char *set_sql = NULL; + char *where_sql = NULL; + + if((_folder != NULL) && STRING_VALID(_folder->folder_id) && g_src_path) + { + /* Set modified time */ + time_t date; + time(&date); + _folder->modified_time = date; + + set_sql = __media_folder_get_update_folder_sql((media_folder_h)_folder); + if(set_sql == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + where_sql = sqlite3_mprintf("folder_uuid='%q'", _folder->folder_id); + + len = snprintf(sql, sizeof(sql), UPDATE_SQL, DB_TABLE_FOLDER, set_sql, where_sql); + if (len > 0) { + sql[len] = '\0'; + } else { + media_content_error("snprintf failed"); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _content_query_sql(sql); + + sqlite3_free(set_sql); + sqlite3_free(where_sql); + + /* Do folder rename operation using libmedia-service */ + ret = media_svc_rename_folder(_content_get_db_handle(), g_src_path, _folder->path); + return _content_error_capi(MEDIA_CONTENT_TYPE, ret); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_folder_set_name(media_folder_h folder, const char *name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_folder_s *_folder = (media_folder_s*)folder; + + if(_folder != NULL && STRING_VALID(name)) + { + if (STRING_VALID(_folder->path) && STRING_VALID(_folder->name)) { + char *folder_path = NULL; + char new_folder_path[MAX_QUERY_SIZE] = {0,}; + + folder_path = g_path_get_dirname(_folder->path); + media_content_debug("Existed Folder Path : %s", _folder->path); + snprintf(new_folder_path, sizeof(new_folder_path), "%s/%s", folder_path, name); + media_content_debug("New Path : %s", new_folder_path); + + SAFE_FREE(g_src_path); + g_src_path = strdup(_folder->path); + + SAFE_FREE(_folder->path); + SAFE_FREE(_folder->name); + _folder->path = strdup(new_folder_path); + + if(_folder->path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _folder->name = strdup(name); + if(_folder->name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} diff --git a/src/media_group.c b/src/media_group.c new file mode 100755 index 0000000..3312fbf --- /dev/null +++ b/src/media_group.c @@ -0,0 +1,418 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_filter.h> +#include <media_info.h> +#include <media_info_private.h> +#include <media_group.h> + + +int media_album_get_album_count_from_db(filter_h filter, int *album_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(album_count != NULL) + { + ret = _media_db_get_group_count(filter, MEDIA_GROUP_ALBUM, album_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_foreach_album_from_db(filter_h filter, media_album_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_album(filter, callback, user_data); + + return ret; +} + +int media_album_get_media_count_from_db(int album_id, filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((album_id > 0) && (media_count != NULL)) + { + ret = _media_db_get_group_item_count_by_id(album_id, filter, MEDIA_GROUP_ALBUM, media_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_foreach_media_from_db(int album_id, filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((album_id > 0) && (callback != NULL)) + { + ret = _media_db_get_group_item_by_id(album_id, filter, callback, user_data, MEDIA_GROUP_ALBUM); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_get_album_from_db(int album_id, media_album_h *album) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + + media_content_debug_func(); + + if(album_id < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_ALBUM_FROM_ALBUM, album_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_album_s *_album = (media_album_s*)calloc(1, sizeof(media_album_s)); + + _album->album_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _album->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _album->artist = strdup((const char *)sqlite3_column_text(stmt, 2)); + + *album = (media_album_h)_album; + } + + if(stmt != NULL) + { + sqlite3_finalize(stmt); + } + + return ret; +} + +int media_album_destroy(media_album_h album) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_album = (media_album_s*)album; + + media_content_debug_func(); + + if(_album) + { + SAFE_FREE(_album->name); + SAFE_FREE(_album->artist); + SAFE_FREE(_album->album_art_path); + SAFE_FREE(_album); + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_clone(media_album_h *dst, media_album_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_src = (media_album_s*)src; + + if(_src != NULL) + { + media_album_s *_dst = (media_album_s*)calloc(1, sizeof(media_album_s)); + + if(_dst == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _dst->album_id = _src->album_id; + + if(STRING_VALID(_src->name)) + { + _dst->name = strdup(_src->name); + if(_dst->name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_album_destroy((media_album_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->artist)) + { + _dst->artist = strdup(_src->artist); + if(_dst->artist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_album_destroy((media_album_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->album_art_path)) + { + _dst->album_art_path = strdup(_src->album_art_path); + if(_dst->album_art_path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_album_destroy((media_album_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + *dst = (media_album_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_get_album_id(media_album_h album, int *album_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_album = (media_album_s*)album; + + if(_album && album_id) + { + *album_id = _album->album_id; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_get_name(media_album_h album, char **name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_album = (media_album_s*)album; + + if(_album) + { + if(STRING_VALID(_album->name)) + { + *name = strdup(_album->name); + if(*name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *name = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_get_artist(media_album_h album, char **artist) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_album = (media_album_s*)album; + + if(_album) + { + if(STRING_VALID(_album->artist)) + { + *artist = strdup(_album->artist); + if(*artist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *artist = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_album_get_album_art(media_album_h album, char **album_art) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_s *_album = (media_album_s*)album; + + if(_album) + { + if(STRING_VALID(_album->album_art_path)) + { + *album_art = strdup(_album->album_art_path); + if(*album_art == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *album_art = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_group_get_group_count_from_db(filter_h filter, media_group_e group, int *group_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD) || (group_count == NULL)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + else + { + ret = _media_db_get_media_group_count(group, filter, group_count); + } + + return ret; +} + +int media_group_foreach_group_from_db(filter_h filter, media_group_e group, media_group_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + else + { + ret = _media_db_get_media_group(group, filter, callback, user_data); + } + + return ret; +} + +int media_group_get_media_count_from_db(const char *group_name, media_group_e group, filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((media_count == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + else + { + ret = _media_db_get_media_group_item_count(group_name, group, filter, media_count); + } + + return ret; +} + +int media_group_foreach_media_from_db(const char *group_name, media_group_e group, filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((callback == NULL) || (group < MEDIA_CONTENT_GROUP_DISPLAY_NAME) || (group > MEDIA_CONTENT_GROUP_KEYWORD)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + else + { + ret = _media_db_get_media_group_item(group_name, group, filter, callback, user_data); + } + + return ret; +} diff --git a/src/media_image.c b/src/media_image.c index 1a7a006..c317654 100644..100755 --- a/src/media_image.c +++ b/src/media_image.c @@ -11,180 +11,136 @@ * 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. +* limitations under the License. */ - #include <media_image.h> #include <media_content.h> #include <media_info_private.h> -#include <visual-svc-types.h> -#include <visual-svc.h> #include <media-svc.h> -#include <dlog.h> - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "TIZEN_N_MEDIACONTENT" - - - -#define DUPLICATE_STRING(destination, src) \ -{ \ - char* tmp = src; \ - if(tmp != NULL && strlen(tmp) > 0) \ - { \ - char* new_str = strdup(tmp); \ - destination = new_str; \ - } \ - else \ - { \ - destination = NULL; \ - } \ -} - -#define DUPLICATE_FIELD(field) DUPLICATE_STRING(_dst->field, _src->field) int image_meta_destroy(image_meta_h image) { - int ret; - image_meta_s* _image = (image_meta_s*)image; + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + + media_content_debug_func(); + if(_image) { - if(_image->image_id) - free(_image->image_id); - if(_image->thumbnail) - free(_image->thumbnail); - if(_image->description) - free(_image->description); - - free(_image); + SAFE_FREE(_image->media_id); + SAFE_FREE(_image->date_taken); + SAFE_FREE(_image); + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - return ret; + return ret; } - -int image_meta_clone(image_meta_h* dst, image_meta_h src) +int image_meta_clone(image_meta_h *dst, image_meta_h src) { - int ret; - image_meta_s* _src = (image_meta_s*)src; + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_src = (image_meta_s*)src; + + media_content_debug_func(); if(_src != NULL) { - - image_meta_s* _dst = (image_meta_s*)calloc(1,sizeof(image_meta_s)); - if (NULL == _dst) + image_meta_s *_dst = (image_meta_s*)calloc(1, sizeof(image_meta_s)); + if(NULL == _dst) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - _dst->image_id = strdup(_src->image_id); - _dst->longitude = _src->longitude; - _dst->latitude= _src->latitude; - _dst->width = _src->width; - _dst->height = _src->height; - _dst->orientation = _src->orientation; - _dst->date_taken = _src->date_taken; - DUPLICATE_FIELD(thumbnail) - DUPLICATE_FIELD(description) - - ret = MEDIA_CONTENT_ERROR_NONE; - *dst = (image_meta_h)_dst; - } - else - { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } - - return ret; + if(STRING_VALID(_src->media_id)) + { + _dst->media_id = strdup(_src->media_id); + if(_dst->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + image_meta_destroy((image_meta_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + _dst->media_id = strdup(_src->media_id); + } -} + if(STRING_VALID(_src->date_taken)) + { + _dst->date_taken = strdup(_src->date_taken); + if(_dst->date_taken == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + image_meta_destroy((image_meta_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + _dst->date_taken = strdup(_src->date_taken); + } -int image_meta_get_longitude(image_meta_h image, double* longitude) -{ - int ret; - image_meta_s* _image = (image_meta_s*)image; - if(_image && longitude) - { - *longitude= _image->longitude; - ret = MEDIA_CONTENT_ERROR_NONE; - } - else - { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + _dst->width = _src->width; + _dst->height = _src->height; + _dst->orientation = _src->orientation; - return ret; + *dst = (image_meta_h)_dst; -} -int image_meta_get_latitude(image_meta_h image, double* latitude) -{ - int ret; - image_meta_s* _image = (image_meta_s*)image; - if(_image && latitude) - { - *latitude = _image->latitude; ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int image_meta_get_description(image_meta_h image, char** description) +int image_meta_get_media_id(image_meta_h image, char **media_id) { - int ret; - image_meta_s* _image = (image_meta_s*)image; - if(_image && description) + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + + if(_image) { - if((_image->description != NULL) && (strlen(_image->description) > 0)) + if(STRING_VALID(_image->media_id)) { - *description = strdup(_image->description); - if (NULL == *description) + char *new_string = strdup(_image->media_id); + if(NULL == new_string) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } + *media_id = new_string; } else { - *description = NULL; + *media_id = NULL; } ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; } -int image_meta_get_width(image_meta_h image, int* width) + +int image_meta_get_width(image_meta_h image, int *width) { - int ret; - image_meta_s* _image = (image_meta_s*)image; + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + if(_image && width) { *width = _image->width; @@ -192,17 +148,17 @@ int image_meta_get_width(image_meta_h image, int* width) } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int image_meta_get_height(image_meta_h image, int* height) +int image_meta_get_height(image_meta_h image, int *height) { - int ret; - image_meta_s* _image = (image_meta_s*)image; + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + if(_image && height) { *height = _image->height; @@ -210,17 +166,17 @@ int image_meta_get_height(image_meta_h image, int* height) } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } + int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation) { - int ret; - image_meta_s* _image = (image_meta_s*)image; + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; if(_image) { *orientation = _image->orientation; @@ -228,30 +184,85 @@ int image_meta_get_orientation(image_meta_h image, media_content_orientation_e* } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int image_meta_get_date_taken(image_meta_h image,time_t* date_taken) + +int image_meta_get_date_taken(image_meta_h image, char **date_taken) { - int ret; - image_meta_s* _image = (image_meta_s*)image; - if(_image && date_taken) + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + + if(_image) { - *date_taken = _image->date_taken; + if(STRING_VALID(_image->date_taken)) + { + char *new_string = strdup(_image->date_taken); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *date_taken = new_string; + } + else + { + *date_taken = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; +} + +int image_meta_set_orientation(image_meta_h image, media_content_orientation_e orientation) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + + if(_image == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if((orientation < MEDIA_CONTENT_ORIENTATION_NOT_AVAILABLE) || (orientation > MEDIA_CONTENT_ORIENTATION_ROT_270)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + _image->orientation = orientation; + + return ret; } +int image_meta_update_to_db(image_meta_h image) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + image_meta_s *_image = (image_meta_s*)image; + char *sql = NULL; + if(_image != NULL && STRING_VALID(_image->media_id)) + { + sql = sqlite3_mprintf(UPDATE_IMAGE_META_FROM_MEDIA, _image->orientation, _image->media_id); + ret = _content_query_sql(sql); + sqlite3_free(sql); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +}
\ No newline at end of file diff --git a/src/media_info.c b/src/media_info.c index 9da7502..bf260f7 100644..100755 --- a/src/media_info.c +++ b/src/media_info.c @@ -1,1031 +1,2520 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <media_content.h>
-#include <media_info_private.h>
-#include <media-svc.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <audio-svc-types.h>
-
-#include <visual-svc-error.h>
-#include <visual-svc-types.h>
-#include <visual-svc.h>
-
-#include <drm-service.h>
-#include <aul.h>
-
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-//extern MediaSvcHandle* db_handle;
-
-
-#define SELECT_AUDIO_FROM_MEDIA "select audio_uuid,genre,album,artist,author,year,copyright,description,format,bitrate,track_num,duration,rating,played_count,last_played_time,added_time,size,category from audio_media where audio_uuid='%s' "
-#define SELECT_TAG_LIST_FROM_MEDIA "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=0; "
-
-int media_info_insert_to_db(media_content_type_e type,const char* path)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
- int storage_type;
- int category=0;
- minfo_file_type _type;
- if(path == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- switch(type)
- {
- case MEDIA_CONTENT_TYPE_IMAGE:
- _type = MINFO_ITEM_IMAGE;
- ret = minfo_add_media(_content_get_db_handle(), path, _type);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- break;
- case MEDIA_CONTENT_TYPE_VIDEO:
- _type = MINFO_ITEM_VIDEO;
- ret = minfo_add_media(_content_get_db_handle(), path, _type);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
- break;
-
- case MEDIA_CONTENT_TYPE_AUDIO:
- storage_type = _content_get_storage_type(path);
- ret = _content_get_audio_category(path,&category);
- if(ret >= 0)
- {
- ret = audio_svc_insert_item(_content_get_db_handle(), storage_type,path,category);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- break;
-
- default:
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- break;
-
- }
-
- return ret;
-}
-
-
-
-int media_info_destroy(media_info_h item)
-{
-
- int ret;
- media_info_s* _item = (media_info_s*)item;
- if(_item)
- {
- if(_item->item_id)
- {
- free(_item->item_id);
- }
-
- if(_item->file_path)
- {
- free(_item->file_path);
- }
- if(_item->display_name)
- {
- free(_item->display_name);
- }
- if(_item->thumbnail)
- {
- free(_item->thumbnail);
- }
- free(_item);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-
-
-}
-int media_info_clone(media_info_h* dst, media_info_h src)
-{
- int ret;
- media_info_s* _src = (media_info_s*)src;
-
-
- if(_src != NULL )
- {
- media_info_s* _dst = (media_info_s*)calloc(1,sizeof(media_info_s));
-
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _dst->item_id = strdup(_src->item_id);
- if( _dst->item_id == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- _dst->date_modified= _src->date_modified;
- _dst->favorite = _src->favorite;
- _dst->media_type = _src->media_type;
- if((_src->file_path != NULL) && (strlen(_src->file_path) > 0))
- {
- _dst->file_path = strdup(_src->file_path);
- if(_dst->file_path == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->display_name != NULL) && (strlen(_src->display_name) > 0))
- {
- _dst->display_name = strdup(_src->display_name);
- if(_dst->display_name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- if((_src->thumbnail != NULL) && (strlen(_src->thumbnail) > 0))
- {
- _dst->thumbnail = strdup(_src->thumbnail);
- if(_dst->thumbnail == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- media_info_destroy((media_info_h)_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- }
- *dst = (media_info_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_info_get_file_path(media_info_h item, char** path)
-{
- int ret;
- media_info_s* _item = (media_info_s*)item;
-
- if(_item)
- {
- if((_item->file_path != NULL) && (strlen(_item->file_path) > 0))
- {
- *path = strdup(_item->file_path);
- if(*path == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *path = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-int media_info_get_display_name(media_info_h item, char** name)
-{
- int ret;
- media_info_s* _item = (media_info_s*)item;
- if(_item)
- {
- if((_item->display_name != NULL) && (strlen(_item->display_name) > 0))
- {
- *name = strdup(_item->display_name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-int media_info_get_thumbnail_path(media_info_h item, char** path)
-{
- int ret;
- media_info_s* _item = (media_info_s*)item;
- if(_item)
- {
- if((_item->thumbnail != NULL) && (strlen(_item->thumbnail) > 0))
- {
- *path = strdup(_item->thumbnail);
- if(*path == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *path = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-
-int media_info_get_date_modified(media_info_h item, time_t* time)
-{
- int ret;
- media_info_s* _item = (media_info_s*)item;
- if(_item)
- {
- *time = _item->date_modified;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-int media_info_get_media_type(media_info_h item, int* type)
-{
- int ret;
- media_info_s* _item = (media_info_s*)item;
- if(_item)
- {
- *type = _item->media_type;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-int media_info_get_favorite(media_info_h media, int* favorite)
-{
- int ret;
- media_info_s* _media = (media_info_s*)media;
- if(_media)
- {
-
- *favorite = _media->favorite;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-
-
-int media_info_update_favorite_to_db(media_info_h media, int favorite)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- media_info_s* _media = (media_info_s*)media;
-
- if(media != NULL)
- {
- if(_media->media_type == MEDIA_CONTENT_TYPE_AUDIO)
- {
- if(favorite)
- {
- ret = audio_svc_add_item_to_playlist( _content_get_db_handle(), AUDIO_SVC_FAVORITE_LIST_ID, _media->item_id);
- }
- else
- {
- ret = audio_svc_remove_item_from_playlist_by_audio_id(_content_get_db_handle(), AUDIO_SVC_FAVORITE_LIST_ID, _media->item_id);
- }
- }
- else
- {
- ret = minfo_update_media_favorite(_content_get_db_handle(), _media->item_id,favorite);
- }
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- {
- _media->favorite = favorite;
- }
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-
- }
- return ret;
-
-}
-
-
-
-int media_info_foreach_media_from_db(media_info_filter_h filter,media_info_cb callback, void* user_data)
-{
- int ret= MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char condition_query[DEFAULT_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char condition_type[MIN_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
- char order_query[MIN_QUERY_SIZE];
-
-
- sqlite3_stmt *stmt = NULL;
-
-
- media_info_filter_s* _filter = NULL;
-
- if( callback == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
-
- if(filter != NULL)
- {
- _filter = (media_info_filter_s*)filter;
-
- if(!(_filter->media_type & (MEDIA_CONTENT_TYPE_IMAGE | MEDIA_CONTENT_TYPE_VIDEO | MEDIA_CONTENT_TYPE_AUDIO)) )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- ret = media_info_filter_create((media_info_filter_h*)&_filter);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- return ret;
- }
-
- if(_filter->media_type == 0)
- {
- _filter->media_type = (MEDIA_CONTENT_TYPE_IMAGE | MEDIA_CONTENT_TYPE_VIDEO | MEDIA_CONTENT_TYPE_AUDIO);
- }
- }
-
- memset(order_query,0x00,sizeof(order_query));
- memset(condition_type,0x00,sizeof(condition_type));
- memset(condition_query,0x00,sizeof(condition_query));
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(select_query,0x00,sizeof(select_query));
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_info_filter_s*)filter != _filter)
- media_info_filter_destroy((media_info_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
-
- if(_filter->media_type & MEDIA_CONTENT_TYPE_IMAGE)
- {
- strncat(condition_type,CONDITION_TYPE_IMAGE,strlen(CONDITION_TYPE_IMAGE));
- }
- if(_filter->media_type & MEDIA_CONTENT_TYPE_VIDEO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
- strncat(condition_type,CONDITION_TYPE_VIDEO,strlen(CONDITION_TYPE_VIDEO));
-
- }
- if(_filter->media_type & MEDIA_CONTENT_TYPE_AUDIO)
- {
- if(strlen(condition_type) > 0 )
- {
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- strncat(condition_type,QUERY_KEYWORD_OR, strlen(QUERY_KEYWORD_OR));
- strncat(condition_type,QUERY_KEYWORD_SPACE, strlen(QUERY_KEYWORD_SPACE));
- }
-
- strncat(condition_type,CONDITION_TYPE_AUDIO,strlen(CONDITION_TYPE_AUDIO));
- }
-
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_MEDIA_ITEM);
-
- snprintf(condition_query,sizeof(condition_query), "%s (%s)", QUERY_KEYWORD_AND, condition_type);
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DATE_MODIFIED);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DATE_MODIFIED,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_info_filter_s*)filter != _filter)
- media_info_filter_destroy((media_info_filter_h)_filter);
-
-
- ret = _content_query_prepare(&stmt,select_query,condition_query, search_query,limit_query,order_query);
- if( ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* item1 = (media_info_s*)calloc(1,sizeof(media_info_s));
-
- if(item1 == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- _content_item_get_detail(stmt,(media_info_h)item1);
-
- if( callback((media_info_h)item1,user_data) == false)
- {
- media_info_destroy((media_info_h) item1);
- break;
- }
- media_info_destroy((media_info_h) item1);
- }
-
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-
-
-int media_info_get_image_from_db(media_info_h item, image_meta_h* image)
-{
- int p_ret;
- int ret = MEDIA_CONTENT_ERROR_NONE;
- Mitem* p_item = NULL;
- image_meta_s* _image = NULL;
-
-
-
- media_info_s* _item = (media_info_s*)item;
-
- if( _item == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_item->media_type != MEDIA_CONTENT_TYPE_IMAGE)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- p_ret = minfo_get_item_by_id(_content_get_db_handle(), _item->item_id,&p_item);
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
- if( (ret == MEDIA_CONTENT_ERROR_NONE) && ( p_item != NULL))
- {
- ret = minfo_get_meta_info(_content_get_db_handle(), _item->item_id,&(p_item->meta_info));
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
-
- if( ret != MEDIA_CONTENT_ERROR_NONE)
- {
- minfo_destroy_mtype_item(p_item);
- return ret;
- }
- _image = (image_meta_s*)calloc(1, sizeof(image_meta_s));
- if(_image == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- minfo_destroy_mtype_item(p_item);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
-
- }
-
- _image->image_id = strdup(p_item->uuid);
- if(p_item->thumb_url != NULL)
- _image->thumbnail = strdup(p_item->thumb_url);
- if(p_item->rate > 0)
- _image->favorite = true;
- else
- _image->favorite = false;
-
- if(p_item->meta_info != NULL)
- {
- _image->longitude = p_item->meta_info->longitude;
- _image->latitude = p_item->meta_info->latitude;
- _image->width = p_item->meta_info->width;
- _image->height = p_item->meta_info->height;
- _image->date_taken = p_item->meta_info->datetaken;
- if(p_item->meta_info->description != NULL)
- _image->description = strdup(p_item->meta_info->description);
- }
- if((p_item->meta_info != NULL) && (p_item->meta_info->image_info != NULL))
- {
- _image->orientation = p_item->meta_info->image_info->orientation;
- }
-
- *image = (image_meta_h)_image;
- p_ret = minfo_destroy_mtype_item(p_item);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
- }
-
-
- return ret;
-}
-
-
-int media_info_get_video_from_db(media_info_h item, video_meta_h* video)
-{
-
- int p_ret;
- int ret = MEDIA_CONTENT_ERROR_NONE;
- Mitem* p_item = NULL;
- video_meta_s* _video = NULL;
-
-
- media_info_s* _item = (media_info_s*)item;
- if( _item == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_item->media_type != MEDIA_CONTENT_TYPE_VIDEO)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- p_ret = minfo_get_item_by_id(_content_get_db_handle(), _item->item_id,&p_item);
-
-
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
- if( (ret == MEDIA_CONTENT_ERROR_NONE) && ( p_item != NULL))
- {
- ret = minfo_get_meta_info(_content_get_db_handle(), _item->item_id,&(p_item->meta_info));
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
- if( ret != MEDIA_CONTENT_ERROR_NONE)
- {
- minfo_destroy_mtype_item(p_item);
- return ret;
- }
-
- _video = (video_meta_s*)calloc(1,sizeof(video_meta_s));
- if( _video == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- minfo_destroy_mtype_item(p_item);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _video->video_id = strdup(p_item->uuid);
- if(p_item->thumb_url)
- _video->thumbnail = strdup(p_item->thumb_url);
-
- if(p_item->rate > 0)
- _video->favorite = true;
- else
- _video->favorite = false;
-
-
- if(p_item->meta_info != NULL)
- {
- _video->longitude = p_item->meta_info->longitude;
- _video->latitude = p_item->meta_info->latitude;
- _video->width = p_item->meta_info->width;
- _video->height = p_item->meta_info->height;
- _video->date_taken = p_item->meta_info->datetaken;
- if(p_item->meta_info->description)
- _video->description = strdup(p_item->meta_info->description);
- }
- if((p_item->meta_info != NULL) && (p_item->meta_info->video_info != NULL))
- {
- if(p_item->meta_info->video_info->album_name != NULL)
- {
- _video->album = strdup(p_item->meta_info->video_info->album_name);
- }
- if(p_item->meta_info->video_info->artist_name != NULL)
- _video->artist = strdup(p_item->meta_info->video_info->artist_name);
- if(p_item->meta_info->video_info->title != NULL)
- _video->title = strdup(p_item->meta_info->video_info->title);
-
-
- _video->time_played = p_item->meta_info->video_info->last_played_pos;
- _video->duration = p_item->meta_info->video_info->duration;
- }
- *video = (video_meta_h)_video;
- p_ret = minfo_destroy_mtype_item(p_item);
- ret = _content_error_capi(MEDIA_CONTENT_TYPE,p_ret);
-
- }
- return ret;
-}
-
-int media_info_get_audio_from_db(media_info_h item, audio_meta_h* audio)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_info_s* _item = (media_info_s*)item;
-
- char select_query[DEFAULT_QUERY_SIZE];
- sqlite3_stmt *stmt = NULL;
-
- if(_item == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_item->media_type != MEDIA_CONTENT_TYPE_AUDIO)
- {
- LOGE("[%s] the type of media is not an audio.",__func__);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- memset(select_query,0x00,sizeof(select_query));
-
- snprintf(select_query,sizeof(select_query), SELECT_AUDIO_FROM_MEDIA,_item->item_id);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,NULL,NULL,NULL);
-
-
- if( ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- audio_meta_s* _audio = (audio_meta_s*)calloc(1,sizeof(audio_meta_s));
- if(_audio == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- _audio->audio_id = strdup((const char *)sqlite3_column_text(stmt, 0));
- _audio->genre = strdup((const char *)sqlite3_column_text(stmt, 1));
- _audio->album = strdup((const char *)sqlite3_column_text(stmt, 2));
- _audio->artist= strdup((const char *)sqlite3_column_text(stmt, 3));
- _audio->author= strdup((const char *)sqlite3_column_text(stmt, 4));
- _audio->year= strdup((const char *)sqlite3_column_text(stmt, 5));
- _audio->copyright= strdup((const char *)sqlite3_column_text(stmt, 6));
- _audio->description= strdup((const char *)sqlite3_column_text(stmt, 7));
- _audio->format= strdup((const char *)sqlite3_column_text(stmt, 8));
- _audio->bitrate = (int)sqlite3_column_int(stmt,9);
- _audio->track_num = (int)sqlite3_column_int(stmt,10);
- _audio->duration = (int)sqlite3_column_int(stmt,11);
- _audio->rating = (int)sqlite3_column_int(stmt,12);
- _audio->count_played = (int)sqlite3_column_int(stmt,13);
- _audio->time_played = (int)sqlite3_column_int(stmt,14);
- _audio->time_added = (int)sqlite3_column_int(stmt,15);
- _audio->size = (int)sqlite3_column_int(stmt,16);
- _audio->category = (int)sqlite3_column_int(stmt,17);
- }
- *audio = (audio_meta_h)_audio;
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
-
- return ret;
-}
-
-
-
-int media_info_foreach_tag_from_db(media_info_h item, media_tag_cb callback, void *user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char select_query[DEFAULT_QUERY_SIZE];
- sqlite3_stmt *stmt = NULL;
-
- media_info_s* _item = (media_info_s*)item;
-
- if(_item == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- if(callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- snprintf(select_query,sizeof(select_query),SELECT_TAG_LIST_FROM_MEDIA,_item->item_id);
- ret = _content_query_prepare(&stmt,select_query,NULL,NULL,NULL,NULL);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_tag_s* _tag = (media_tag_s*)calloc(1,sizeof(media_tag_s));
-
- if(_tag == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _tag->tag_id = (int)sqlite3_column_int(stmt,0);
- _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1));
- if(callback((media_tag_h)_tag,user_data) == false)
- {
- media_tag_destroy((media_tag_h) _tag);
- break;
- }
- media_tag_destroy((media_tag_h) _tag);
-
- }
-
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-
-}
-
-void _content_item_get_detail(sqlite3_stmt* stmt, media_info_h item)
-{
- //item_id, file_path, display_name, thumbnail, date_modified,content_type, valid
- media_info_s* _item = (media_info_s*)item;
- _item->item_id = strdup((const char *)sqlite3_column_text(stmt, 0));
- _item->file_path= strdup((const char *)sqlite3_column_text(stmt, 1));
- _item->display_name=strdup((const char *)sqlite3_column_text(stmt, 2));
- _item->thumbnail=strdup((const char *)sqlite3_column_text(stmt, 3));
- _item->date_modified = (int)sqlite3_column_int(stmt,4);
- _item->media_type = (int)sqlite3_column_int(stmt,5);
- _item->media_type = _item->media_type==3?4:_item->media_type;
- _item->favorite = (int)sqlite3_column_int(stmt,6);
-}
-
-int _content_get_storage_type(const char* full_path)
-{
- if (full_path != NULL) {
- if (strncmp(full_path, MEDIA_CONTENT_PATH_PHONE , strlen(MEDIA_CONTENT_PATH_PHONE )) == 0)
- {
- return MEDIA_CONTENT_STORAGE_INTERNAL;
- }
- else if (strncmp(full_path, MEDIA_CONTENT_PATH_MMC , strlen(MEDIA_CONTENT_PATH_MMC )) == 0)
- {
- return MEDIA_CONTENT_STORAGE_EXTERNAL;
- }
- }
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
-}
-
-
-#define CONTENT_TYPE_NUM 4
-#define FEX_CATEGORY_UNKNOWN 0x00000000 /**< Default */
-#define FEX_CATEGORY_ETC 0x00000001 /**< ETC category */
-#define FEX_CATEGORY_IMAGE 0x00000002 /**< Image category */
-#define FEX_CATEGORY_VIDEO 0x00000004 /**< Video category */
-#define FEX_CATEGORY_MUSIC 0x00000008 /**< Music category */
-#define FEX_CATEGORY_SOUND 0x00000010 /**< Sound category */
-#define FEX_CATEGORY_DRM 0x00000020 /**< DRM category */
-#define SOUND_MIME_NUM 1
-#define MINE_LENGTH 30
-#define MUSIC_MIME_NUM 12
-
-
-typedef struct
-{
- char content_type[15];
- int category_by_mime;
-}fex_content_table_t;
-
-static const fex_content_table_t content_category[CONTENT_TYPE_NUM] = {
- {"audio", FEX_CATEGORY_SOUND},
- {"image", FEX_CATEGORY_IMAGE},
- {"video", FEX_CATEGORY_VIDEO},
- {"application", FEX_CATEGORY_ETC},
-};
-
-static const char sound_mime_table[SOUND_MIME_NUM][MINE_LENGTH] = {
- "x-smaf",
-};
-static const char music_mime_table[MUSIC_MIME_NUM][MINE_LENGTH] = {
- "ac3",
- "mp2",
- "mpeg",
- "ogg",
- "vnd.rn-realaudio",
- "x-ape",
- "x-flac",
- "x-flac+ogg",
- "x-matroska",
- "x-ms-asx",
- "x-ms-wma",
- "x-vorbis+ogg",
-};
-
-#define FMS_DRM_CONTENT_TYPE_LENGTH 100
-
-int _content_get_audio_category(const char* file_full_path,int* category)
-{
- int i = 0;
- char mimetype[255] = {0,};
- int result = 0;
- bool is_drm = false;
- drm_content_info_t contentInfo = {0};
-
- if (file_full_path == NULL)
- return FEX_CATEGORY_UNKNOWN;
-
-
- if (drm_svc_is_drm_file(file_full_path) == DRM_TRUE)
- {
-
- // 2008.8.13 han. In this case, use drm_svc_get_content_info api.
- result = drm_svc_get_content_info(file_full_path, &contentInfo);
- if (result != DRM_RESULT_SUCCESS)
- {
- *category = FEX_CATEGORY_UNKNOWN;
- }
-
- strncpy(mimetype, contentInfo.contentType, strlen(contentInfo.contentType)+1);
- *category = *category | FEX_CATEGORY_DRM;
- is_drm = true;
- }
- else
- {
- result = aul_get_mime_from_file(file_full_path, mimetype, sizeof(mimetype));
- if(result < 0)
- {
- *category = FEX_CATEGORY_UNKNOWN;
- }
-
- }
-
- for(i = 0; i < CONTENT_TYPE_NUM; i ++)
- {
- if (strstr(mimetype, content_category[i].content_type) != NULL)
- {
- *category = (*category | content_category[i].category_by_mime);
- break;
- }
- }
- if (*category & FEX_CATEGORY_ETC)
- {
- int prefix_len = strlen(content_category[0].content_type);
-
- for(i = 0; i < SOUND_MIME_NUM; i ++)
- {
- if (strstr(mimetype+prefix_len, sound_mime_table[i]) != NULL)
- {
- *category = FEX_CATEGORY_SOUND;
- break;
- }
- }
-
- if(is_drm)
- *category = *category | FEX_CATEGORY_DRM;;
- }
-
- if (!(*category & FEX_CATEGORY_SOUND))
- {
- return result;
- }
- else
- {
- if(is_drm) //if sound file is DRM, it is always music file.
- {
- *category = FEX_CATEGORY_MUSIC;
- *category = *category | FEX_CATEGORY_DRM;
- }
- else //check music file in sound files.
- {
- int prefix_len = strlen(content_category[0].content_type);
-
- for(i = 0; i < MUSIC_MIME_NUM; i ++)
- {
- if (strstr(mimetype+prefix_len, music_mime_table[i]) != NULL)
- {
- *category = FEX_CATEGORY_MUSIC;
- break;
- }
- }
- }
- }
-
- return result;
-
-
-
-}
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> +#include <media_util_private.h> +#include <media-svc.h> +#include <media-util-register.h> +#include <media-util-err.h> + + +static int __media_info_get_media_info_from_db(char *path, media_info_h media); +static void __media_info_image_item_get_detail(sqlite3_stmt* stmt, image_meta_h image); +static void __media_info_video_item_get_detail(sqlite3_stmt* stmt, video_meta_h video); +static void __media_info_audio_item_get_detail(sqlite3_stmt* stmt, audio_meta_h audio); + +static int __media_info_get_media_info_from_db(char *path, media_info_h media) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char *select_query = NULL; + media_info_s *_media = (media_info_s*)media; + + if(_media == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + select_query = sqlite3_mprintf(SELECT_MEDIA_BY_PATH, path); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + sqlite3_free(select_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + if(sqlite3_step(stmt) == SQLITE_ROW) + { + _media_info_item_get_detail(stmt, (media_info_h)_media); + media_content_debug("New Media ID: %s", _media->media_id); + } else { + media_content_debug("There's no media!!"); + } +/* + while(sqlite3_step(stmt) == SQLITE_ROW) + { + _media_info_item_get_detail(stmt, (media_info_h)_media); + media_content_debug("New Media ID: %s", _media->media_id); + } +*/ + SQLITE3_FINALIZE(stmt); + + return ret; +} + +static void __media_info_image_item_get_detail(sqlite3_stmt* stmt, image_meta_h image) +{ + image_meta_s *_image = (image_meta_s*)image; + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _image->media_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + _image->width = sqlite3_column_int(stmt, 1); + + _image->height = sqlite3_column_int(stmt, 2); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3))) + _image->date_taken = strdup((const char *)sqlite3_column_text(stmt, 3)); + + _image->orientation = sqlite3_column_int(stmt, 4); + + return; +} + +static void __media_info_video_item_get_detail(sqlite3_stmt* stmt, video_meta_h video) +{ + video_meta_s *_video = (video_meta_s*)video; + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _video->media_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _video->title = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _video->album = strdup((const char *)sqlite3_column_text(stmt, 2)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3))) + _video->artist = strdup((const char *)sqlite3_column_text(stmt, 3)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4))) + _video->genre = strdup((const char *)sqlite3_column_text(stmt, 4)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 5))) + _video->composer = strdup((const char *)sqlite3_column_text(stmt, 5)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 6))) + _video->year = strdup((const char *)sqlite3_column_text(stmt, 6)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 7))) + _video->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 7)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8))) + _video->copyright = strdup((const char *)sqlite3_column_text(stmt, 8)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9))) + _video->track_num = strdup((const char *)sqlite3_column_text(stmt, 9)); + + _video->bitrate = sqlite3_column_int(stmt, 10); + _video->duration = sqlite3_column_int(stmt, 11); + _video->played_count = sqlite3_column_int(stmt, 12); + _video->played_time = sqlite3_column_int(stmt, 13); + _video->played_position = sqlite3_column_int(stmt, 14); + _video->width = sqlite3_column_int(stmt, 15); + _video->height = sqlite3_column_int(stmt, 16); + + return; +} + +static void __media_info_audio_item_get_detail(sqlite3_stmt* stmt, audio_meta_h audio) +{ + audio_meta_s *_audio = (audio_meta_s*)audio; + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _audio->media_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _audio->title = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _audio->album = strdup((const char *)sqlite3_column_text(stmt, 2)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 3))) + _audio->artist = strdup((const char *)sqlite3_column_text(stmt, 3)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4))) + _audio->genre = strdup((const char *)sqlite3_column_text(stmt, 4)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 5))) + _audio->composer = strdup((const char *)sqlite3_column_text(stmt, 5)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 6))) + _audio->year = strdup((const char *)sqlite3_column_text(stmt, 6)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 7))) + _audio->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 7)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8))) + _audio->copyright = strdup((const char *)sqlite3_column_text(stmt, 8)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9))) + _audio->track_num = strdup((const char *)sqlite3_column_text(stmt, 9)); + + _audio->bitrate = sqlite3_column_int(stmt, 10); + _audio->duration = sqlite3_column_int(stmt, 11); + _audio->played_count = sqlite3_column_int(stmt, 12); + _audio->played_time = sqlite3_column_int(stmt, 13); + _audio->played_position = sqlite3_column_int(stmt, 14); + _audio->samplerate = sqlite3_column_int(stmt, 15); + _audio->channel = sqlite3_column_int(stmt, 16); + + return; +} + +void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media) +{ +//#define MEDIA_INFO_ITEM "media_uuid, path, file_name, media_type, mime_type, size, added_time, modified_time, thumbnail_path, description, +// rating, favourite, author, provider, content_name, category, location_tag, age_rating, keyword, is_drm, storage_type, longitude, latitude, altitude, width, height, datetaken, orientation, title, album, artist, genre, composer, year, recorded_date, copyright, track_num, bitrate, duration, played_count, last_played_time, last_played_position, samplerate, channel" + + media_info_s *_media = (media_info_s*)media; + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 0))) + _media->media_id = strdup((const char *)sqlite3_column_text(stmt, 0)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _media->file_path = strdup((const char *)sqlite3_column_text(stmt, 1)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 2))) + _media->display_name = strdup((const char *)sqlite3_column_text(stmt, 2)); + + _media->media_type = (int)sqlite3_column_int(stmt, 3); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 4))) + _media->mime_type = strdup((const char *)sqlite3_column_text(stmt, 4)); + + _media->size = (unsigned long long)sqlite3_column_int64(stmt, 5); + + _media->added_time = (int)sqlite3_column_int(stmt, 6); + + _media->modified_time = (int)sqlite3_column_int(stmt, 7); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 8))) + _media->thumbnail = strdup((const char *)sqlite3_column_text(stmt, 8)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 9))) + _media->description = strdup((const char *)sqlite3_column_text(stmt, 9)); + + _media->rating = (int)sqlite3_column_int(stmt,10); + + _media->favourite = (int)sqlite3_column_int(stmt, 11); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 12))) + _media->author = strdup((const char *)sqlite3_column_text(stmt, 12)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 13))) + _media->provider = strdup((const char *)sqlite3_column_text(stmt, 13)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 14))) + _media->content_name = strdup((const char *)sqlite3_column_text(stmt, 14)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 15))) + _media->category = strdup((const char *)sqlite3_column_text(stmt, 15)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 16))) + _media->location_tag = strdup((const char *)sqlite3_column_text(stmt, 16)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 17))) + _media->age_rating = strdup((const char *)sqlite3_column_text(stmt, 17)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 18))) + _media->keyword = strdup((const char *)sqlite3_column_text(stmt, 18)); + + _media->is_drm = (int)sqlite3_column_int(stmt, 19); + + _media->storage_type = (int)sqlite3_column_int(stmt, 20); + + _media->longitude = (double)sqlite3_column_double(stmt, 21); + _media->latitude = (double)sqlite3_column_double(stmt, 22); + _media->altitude = (double)sqlite3_column_double(stmt, 23); + + if(_media->media_type == MEDIA_CONTENT_TYPE_IMAGE) { + _media->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s)); + if(_media->image_meta) { + if(STRING_VALID(_media->media_id)) + _media->image_meta->media_id = strdup(_media->media_id); + + _media->image_meta->width = sqlite3_column_int(stmt, 24); + _media->image_meta->height = sqlite3_column_int(stmt, 25); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 26))) + _media->image_meta->date_taken = strdup((const char *)sqlite3_column_text(stmt, 26)); + + _media->image_meta->orientation = sqlite3_column_int(stmt, 27); + } + + } else if(_media->media_type == MEDIA_CONTENT_TYPE_VIDEO) { + _media->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s)); + if(_media->video_meta) { + if(STRING_VALID(_media->media_id)) + _media->video_meta->media_id = strdup(_media->media_id); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28))) + _media->video_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29))) + _media->video_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30))) + _media->video_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31))) + _media->video_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32))) + _media->video_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33))) + _media->video_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34))) + _media->video_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35))) + _media->video_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36))) + _media->video_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36)); + + _media->video_meta->bitrate = sqlite3_column_int(stmt, 37); + _media->video_meta->duration = sqlite3_column_int(stmt, 38); + _media->video_meta->played_count = sqlite3_column_int(stmt, 39); + _media->video_meta->played_time = sqlite3_column_int(stmt, 40); + _media->video_meta->played_position = sqlite3_column_int(stmt, 41); + _media->video_meta->width = sqlite3_column_int(stmt, 24); + _media->video_meta->height = sqlite3_column_int(stmt, 25); + } + + } + else if((_media->media_type == MEDIA_CONTENT_TYPE_MUSIC) || (_media->media_type == MEDIA_CONTENT_TYPE_SOUND)) { + _media->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s)); + if(_media->audio_meta) { + if(STRING_VALID(_media->media_id)) + _media->audio_meta->media_id = strdup(_media->media_id); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 28))) + _media->audio_meta->title = strdup((const char *)sqlite3_column_text(stmt, 28)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 29))) + _media->audio_meta->album = strdup((const char *)sqlite3_column_text(stmt, 29)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 30))) + _media->audio_meta->artist = strdup((const char *)sqlite3_column_text(stmt, 30)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 31))) + _media->audio_meta->genre = strdup((const char *)sqlite3_column_text(stmt, 31)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 32))) + _media->audio_meta->composer = strdup((const char *)sqlite3_column_text(stmt, 32)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 33))) + _media->audio_meta->year = strdup((const char *)sqlite3_column_text(stmt, 33)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 34))) + _media->audio_meta->recorded_date = strdup((const char *)sqlite3_column_text(stmt, 34)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 35))) + _media->audio_meta->copyright = strdup((const char *)sqlite3_column_text(stmt, 35)); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 36))) + _media->audio_meta->track_num = strdup((const char *)sqlite3_column_text(stmt, 36)); + + _media->audio_meta->bitrate = sqlite3_column_int(stmt, 37); + _media->audio_meta->duration = sqlite3_column_int(stmt, 38); + _media->audio_meta->played_count = sqlite3_column_int(stmt, 39); + _media->audio_meta->played_time = sqlite3_column_int(stmt, 40); + _media->audio_meta->played_position = sqlite3_column_int(stmt, 41); + _media->audio_meta->samplerate = sqlite3_column_int(stmt, 42); + _media->audio_meta->channel = sqlite3_column_int(stmt, 43); + } + + } +} + +int _content_get_storage_type(const char *full_path) +{ + if(STRING_VALID(full_path)) { + if(strncmp(full_path, MEDIA_CONTENT_PATH_PHONE, strlen(MEDIA_CONTENT_PATH_PHONE)) == 0) + { + return MEDIA_CONTENT_STORAGE_INTERNAL; + } + else if(strncmp(full_path, MEDIA_CONTENT_PATH_MMC, strlen(MEDIA_CONTENT_PATH_MMC)) == 0) + { + return MEDIA_CONTENT_STORAGE_EXTERNAL; + } + } + + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; +} + +int media_info_insert_to_db (const char *path, media_info_h *info) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + if(!STRING_VALID(path)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(info == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_content_debug("Register: %s", path); + ret = media_file_register(path); + if(ret != MS_MEDIA_ERR_NONE) + { + media_content_error("media_file_register failed"); + return _content_error_capi(MEDIA_REGISTER_TYPE, ret); + } + + media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s)); + if(_media == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _media->file_path = strdup(path); + if(_media->file_path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SAFE_FREE(_media); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + ret = __media_info_get_media_info_from_db(_media->file_path, (media_info_h)_media); + + *info = (media_info_h)_media; + + return ret; +} + +int media_info_delete_from_db(const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + char *query_string = NULL; + + if(!STRING_VALID(media_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + query_string = sqlite3_mprintf(DELETE_MEDIA_FROM_MEDIA, media_id); + + ret = _content_query_sql(query_string); + + sqlite3_free(query_string); + + return ret; +} + +int media_info_destroy(media_info_h media) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media) + { + SAFE_FREE(_media->media_id); + SAFE_FREE(_media->file_path); + SAFE_FREE(_media->display_name); + SAFE_FREE(_media->mime_type); + SAFE_FREE(_media->thumbnail); + SAFE_FREE(_media->description); + SAFE_FREE(_media->author); + SAFE_FREE(_media->provider); + SAFE_FREE(_media->content_name); + SAFE_FREE(_media->category); + SAFE_FREE(_media->location_tag); + SAFE_FREE(_media->age_rating); + SAFE_FREE(_media->keyword); + + if(_media->image_meta) { + SAFE_FREE(_media->image_meta->media_id); + SAFE_FREE(_media->image_meta->date_taken); + + SAFE_FREE(_media->image_meta); + } else if(_media->video_meta) { + SAFE_FREE(_media->video_meta->media_id); + SAFE_FREE(_media->video_meta->title); + SAFE_FREE(_media->video_meta->album); + SAFE_FREE(_media->video_meta->artist); + SAFE_FREE(_media->video_meta->genre); + SAFE_FREE(_media->video_meta->composer); + SAFE_FREE(_media->video_meta->year); + SAFE_FREE(_media->video_meta->recorded_date); + SAFE_FREE(_media->video_meta->copyright); + SAFE_FREE(_media->video_meta->track_num); + + SAFE_FREE(_media->video_meta); + } else if(_media->audio_meta) { + SAFE_FREE(_media->audio_meta->media_id); + SAFE_FREE(_media->audio_meta->title); + SAFE_FREE(_media->audio_meta->album); + SAFE_FREE(_media->audio_meta->artist); + SAFE_FREE(_media->audio_meta->genre); + SAFE_FREE(_media->audio_meta->composer); + SAFE_FREE(_media->audio_meta->year); + SAFE_FREE(_media->audio_meta->recorded_date); + SAFE_FREE(_media->audio_meta->copyright); + SAFE_FREE(_media->audio_meta->track_num); + + SAFE_FREE(_media->audio_meta); + } + + SAFE_FREE(_media); + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_clone(media_info_h *dst, media_info_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_src = (media_info_s*)src; + + + if(_src != NULL) + { + media_info_s *_dst = (media_info_s*)calloc(1, sizeof(media_info_s)); + + if(_dst == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->media_id)) + { + _dst->media_id = strdup(_src->media_id); + if(_dst->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->file_path)) + { + _dst->file_path = strdup(_src->file_path); + if(_dst->file_path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->display_name)) + { + _dst->display_name = strdup(_src->display_name); + if(_dst->display_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->mime_type)) + { + _dst->mime_type = strdup(_src->mime_type); + if(_dst->mime_type == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->thumbnail)) + { + _dst->thumbnail = strdup(_src->thumbnail); + if(_dst->thumbnail == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->description)) + { + _dst->description = strdup(_src->description); + if(_dst->description == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->author)) + { + _dst->author = strdup(_src->author); + if(_dst->author == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->provider)) + { + _dst->provider = strdup(_src->provider); + if(_dst->provider == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->content_name)) + { + _dst->content_name = strdup(_src->content_name); + if(_dst->content_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->category)) + { + _dst->category = strdup(_src->category); + if(_dst->category == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->location_tag)) + { + _dst->location_tag = strdup(_src->location_tag); + if(_dst->location_tag == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->age_rating)) + { + _dst->age_rating = strdup(_src->age_rating); + if(_dst->age_rating == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->keyword)) + { + _dst->keyword = strdup(_src->keyword); + if(_dst->keyword == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->media_type = _src->media_type; + _dst->size = _src->size; + _dst->added_time = _src->added_time; + _dst->modified_time = _src->modified_time; + _dst->longitude = _src->longitude; + _dst->latitude = _src->latitude; + _dst->altitude = _src->altitude; + _dst->rating = _src->rating; + _dst->favourite = _src->favourite; + _dst->is_drm = _src->is_drm; + + if(_src->media_type == MEDIA_CONTENT_TYPE_IMAGE && _src->image_meta) { + _dst->image_meta = (image_meta_s *)calloc(1, sizeof(image_meta_s)); + if(_dst->image_meta == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->image_meta->media_id)) + { + _dst->image_meta->media_id = strdup(_src->image_meta->media_id); + if(_dst->image_meta->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->image_meta->date_taken)) + { + _dst->image_meta->date_taken = strdup(_src->image_meta->date_taken); + if(_dst->image_meta->date_taken == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->image_meta->width = _src->image_meta->width; + _dst->image_meta->height = _src->image_meta->height; + _dst->image_meta->orientation = _src->image_meta->orientation; + + } else if(_src->media_type == MEDIA_CONTENT_TYPE_VIDEO && _src->video_meta) { + _dst->video_meta = (video_meta_s *)calloc(1, sizeof(video_meta_s)); + if(_dst->video_meta == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->video_meta->media_id)) + { + _dst->video_meta->media_id = strdup(_src->video_meta->media_id); + if(_dst->video_meta->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->title)) + { + _dst->video_meta->title = strdup(_src->video_meta->title); + if(_dst->video_meta->title == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->album)) + { + _dst->video_meta->album = strdup(_src->video_meta->album); + if(_dst->video_meta->album == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->artist)) + { + _dst->video_meta->artist = strdup(_src->video_meta->artist); + if(_dst->video_meta->artist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->genre)) + { + _dst->video_meta->genre = strdup(_src->video_meta->genre); + if(_dst->video_meta->genre == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->composer)) + { + _dst->video_meta->composer = strdup(_src->video_meta->composer); + if(_dst->video_meta->composer == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->year)) + { + _dst->video_meta->year = strdup(_src->video_meta->year); + if(_dst->video_meta->year == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->recorded_date)) + { + _dst->video_meta->recorded_date = strdup(_src->video_meta->recorded_date); + if(_dst->video_meta->recorded_date == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->copyright)) + { + _dst->video_meta->copyright = strdup(_src->video_meta->copyright); + if(_dst->video_meta->copyright == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->video_meta->track_num)) + { + _dst->video_meta->track_num = strdup(_src->video_meta->track_num); + if(_dst->video_meta->year == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->video_meta->width = _src->video_meta->width; + _dst->video_meta->height = _src->video_meta->height; + _dst->video_meta->duration = _src->video_meta->duration; + _dst->video_meta->bitrate = _src->video_meta->bitrate; + _dst->video_meta->played_count = _src->video_meta->played_count; + _dst->video_meta->played_time = _src->video_meta->played_time; + _dst->video_meta->played_position = _src->video_meta->played_position; + + } else if((_src->media_type == MEDIA_CONTENT_TYPE_MUSIC || _src->media_type == MEDIA_CONTENT_TYPE_SOUND) && _src->audio_meta) { + _dst->audio_meta = (audio_meta_s *)calloc(1, sizeof(audio_meta_s)); + if(_dst->audio_meta == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_src->audio_meta->media_id)) + { + _dst->audio_meta->media_id = strdup(_src->audio_meta->media_id); + if(_dst->audio_meta->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->title)) + { + _dst->audio_meta->title = strdup(_src->audio_meta->title); + if(_dst->audio_meta->title == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->album)) + { + _dst->audio_meta->album = strdup(_src->audio_meta->album); + if(_dst->audio_meta->album == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->artist)) + { + _dst->audio_meta->artist = strdup(_src->audio_meta->artist); + if(_dst->audio_meta->artist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->genre)) + { + _dst->audio_meta->genre = strdup(_src->audio_meta->genre); + if(_dst->audio_meta->genre == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->composer)) + { + _dst->audio_meta->composer = strdup(_src->audio_meta->composer); + if(_dst->audio_meta->composer == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->year)) + { + _dst->audio_meta->year = strdup(_src->audio_meta->year); + if(_dst->audio_meta->year == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->recorded_date)) + { + _dst->audio_meta->recorded_date = strdup(_src->audio_meta->recorded_date); + if(_dst->audio_meta->recorded_date == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->copyright)) + { + _dst->audio_meta->copyright = strdup(_src->audio_meta->copyright); + if(_dst->audio_meta->copyright == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(STRING_VALID(_src->audio_meta->track_num)) + { + _dst->audio_meta->track_num = strdup(_src->audio_meta->track_num); + if(_dst->audio_meta->year == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_info_destroy((media_info_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->audio_meta->channel = _src->audio_meta->channel; + _dst->audio_meta->samplerate = _src->audio_meta->samplerate; + _dst->audio_meta->duration = _src->audio_meta->duration; + _dst->audio_meta->bitrate = _src->audio_meta->bitrate; + _dst->audio_meta->played_count = _src->audio_meta->played_count; + _dst->audio_meta->played_time = _src->audio_meta->played_time; + _dst->audio_meta->played_position = _src->audio_meta->played_position; + + } + *dst = (media_info_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_media_count_from_db(filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(media_count == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + + return ret; + } + + ret = _media_db_get_group_item_count(NULL, filter, MEDIA_GROUP_NONE, media_count); + + return ret; +} + +int media_info_foreach_media_from_db(filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_group_item(NULL, filter, callback, user_data, MEDIA_GROUP_NONE); + + return ret; +} + +int media_info_get_tag_count_from_db(const char *media_id, filter_h filter, int *tag_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(STRING_VALID(media_id) && tag_count) + { + ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_TAG_BY_MEDIA_ID, tag_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_foreach_tag_from_db(const char *media_id, filter_h filter, media_tag_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((callback != NULL) && STRING_VALID(media_id)) + { + ret = _media_db_get_tag(media_id, filter, callback, user_data); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_bookmark_count_from_db(const char *media_id, filter_h filter, int *bookmark_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(STRING_VALID(media_id) && bookmark_count) + { + ret = _media_db_get_group_item_count(media_id, filter, MEDIA_GROUP_BOOKMARK_BY_MEDIA_ID, bookmark_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_foreach_bookmark_from_db (const char *media_id, filter_h filter, media_bookmark_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((callback != NULL) && STRING_VALID(media_id)) + { + ret = _media_db_get_bookmark(media_id, filter, callback, user_data); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_image(media_info_h media, image_meta_h *image) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_info_s *_media = (media_info_s*)media; + media_content_debug_func(); + + if(_media == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->media_type != MEDIA_CONTENT_TYPE_IMAGE) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->image_meta == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s)); + + if(_image == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_media->media_id)) { + _image->media_id = strdup(_media->media_id); + } + + _image->width = _media->image_meta->width; + _image->height = _media->image_meta->height; + _image->orientation = _media->image_meta->orientation; + + if(STRING_VALID(_media->image_meta->date_taken)) { + _image->date_taken = strdup(_media->image_meta->date_taken); + } + + *image = (image_meta_h)_image; + + return ret; +} + +int media_info_get_video(media_info_h media, video_meta_h *video) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_info_s *_media = (media_info_s*)media; + media_content_debug_func(); + + if(_media == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->media_type != MEDIA_CONTENT_TYPE_VIDEO) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->video_meta == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s)); + + if(_video == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_media->media_id)) { + _video->media_id = strdup(_media->media_id); + } + + if(STRING_VALID(_media->video_meta->title)) { + _video->title = strdup(_media->video_meta->title); + } + if(STRING_VALID(_media->video_meta->album)) { + _video->album = strdup(_media->video_meta->album); + } + if(STRING_VALID(_media->video_meta->artist)) { + _video->artist = strdup(_media->video_meta->artist); + } + if(STRING_VALID(_media->video_meta->genre)) { + _video->genre = strdup(_media->video_meta->genre); + } + if(STRING_VALID(_media->video_meta->composer)) { + _video->composer = strdup(_media->video_meta->composer); + } + if(STRING_VALID(_media->video_meta->year)) { + _video->year = strdup(_media->video_meta->year); + } + if(STRING_VALID(_media->video_meta->recorded_date)) { + _video->recorded_date = strdup(_media->video_meta->recorded_date); + } + if(STRING_VALID(_media->video_meta->copyright)) { + _video->copyright = strdup(_media->video_meta->copyright); + } + if(STRING_VALID(_media->video_meta->track_num)) { + _video->track_num = strdup(_media->video_meta->track_num); + } + + _video->width = _media->video_meta->width; + _video->height = _media->video_meta->height; + _video->duration = _media->video_meta->duration; + _video->bitrate = _media->video_meta->bitrate; + _video->played_count = _media->video_meta->played_count; + _video->played_time = _media->video_meta->played_time; + _video->played_position = _media->video_meta->played_position; + + *video = (video_meta_h)_video; + + return ret; +} + +int media_info_get_audio(media_info_h media, audio_meta_h *audio) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_info_s *_media = (media_info_s*)media; + media_content_debug_func(); + + if(_media == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->media_type != MEDIA_CONTENT_TYPE_MUSIC && _media->media_type != MEDIA_CONTENT_TYPE_SOUND) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + if(_media->audio_meta == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s)); + + if(_audio == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + if(STRING_VALID(_media->media_id)) { + _audio->media_id = strdup(_media->media_id); + } + + if(STRING_VALID(_media->audio_meta->title)) { + _audio->title = strdup(_media->audio_meta->title); + } + if(STRING_VALID(_media->audio_meta->album)) { + _audio->album = strdup(_media->audio_meta->album); + } + if(STRING_VALID(_media->audio_meta->artist)) { + _audio->artist = strdup(_media->audio_meta->artist); + } + if(STRING_VALID(_media->audio_meta->genre)) { + _audio->genre = strdup(_media->audio_meta->genre); + } + if(STRING_VALID(_media->audio_meta->composer)) { + _audio->composer = strdup(_media->audio_meta->composer); + } + if(STRING_VALID(_media->audio_meta->year)) { + _audio->year = strdup(_media->audio_meta->year); + } + if(STRING_VALID(_media->audio_meta->recorded_date)) { + _audio->recorded_date = strdup(_media->audio_meta->recorded_date); + } + if(STRING_VALID(_media->audio_meta->copyright)) { + _audio->copyright = strdup(_media->audio_meta->copyright); + } + if(STRING_VALID(_media->audio_meta->track_num)) { + _audio->track_num = strdup(_media->audio_meta->track_num); + } + + _audio->duration = _media->audio_meta->duration; + _audio->bitrate = _media->audio_meta->bitrate; + _audio->samplerate = _media->audio_meta->samplerate; + _audio->channel = _media->audio_meta->channel; + _audio->played_time = _media->audio_meta->played_time; + _audio->played_count = _media->audio_meta->played_count; + _audio->played_position = _media->audio_meta->played_position; + + *audio = (audio_meta_h)_audio; + + return ret; +} + +int media_info_get_image_from_db(const char *media_id, image_meta_h *image) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + sqlite3_stmt *stmt = NULL; + + media_content_debug_func(); + + if(!STRING_VALID(media_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query,0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_IMAGE_FROM_MEDIA, media_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + image_meta_s *_image = (image_meta_s*)calloc(1, sizeof(image_meta_s)); + if(_image == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + __media_info_image_item_get_detail(stmt, (image_meta_h)_image); + } + + *image = (image_meta_h)_image; + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_info_get_video_from_db(const char *media_id, video_meta_h *video) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + sqlite3_stmt *stmt = NULL; + + media_content_debug_func(); + + if(!STRING_VALID(media_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query,0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_VIDEO_FROM_MEDIA, media_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + video_meta_s *_video = (video_meta_s*)calloc(1, sizeof(video_meta_s)); + if(_video == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + __media_info_video_item_get_detail(stmt, (video_meta_h)_video); + } + + *video = (video_meta_h)_video; + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_info_get_audio_from_db(const char *media_id, audio_meta_h *audio) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + sqlite3_stmt *stmt = NULL; + + media_content_debug_func(); + + if(!STRING_VALID(media_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query,0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_AUDIO_FROM_MEDIA, media_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + audio_meta_s *_audio = (audio_meta_s*)calloc(1, sizeof(audio_meta_s)); + if(_audio == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + __media_info_audio_item_get_detail(stmt, (audio_meta_h)_audio); + } + + *audio = (audio_meta_h)_audio; + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_info_get_media_id(media_info_h media, char **media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && media_id) + { + if(STRING_VALID(_media->media_id)) + { + *media_id = strdup(_media->media_id); + if(*media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *media_id = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_file_path(media_info_h media, char **path) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && path) + { + if(STRING_VALID(_media->file_path)) + { + *path = strdup(_media->file_path); + if(*path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *path = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_display_name(media_info_h media, char **name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + if(_media && name) + { + if(STRING_VALID(_media->display_name)) + { + *name = strdup(_media->display_name); + if(*name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_media_type(media_info_h media, media_content_type_e *type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + if(_media && type) + { + *type = _media->media_type; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_mime_type(media_info_h media, char **mime_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && mime_type) + { + if(STRING_VALID(_media->mime_type)) + { + *mime_type = strdup(_media->mime_type); + if(*mime_type == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *mime_type = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_size(media_info_h media, unsigned long long *size) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && size) + { + *size = _media->size; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_added_time(media_info_h media, time_t *added_time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + if(_media && added_time) + { + *added_time = _media->added_time; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_modified_time(media_info_h media, time_t* time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + if(_media && time) + { + *time = _media->modified_time; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_thumbnail_path(media_info_h media, char **path) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + if(_media && path) + { + if(STRING_VALID(_media->thumbnail)) + { + *path = strdup(_media->thumbnail); + if(*path == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *path = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_description(media_info_h media, char **description) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && description) + { + if(STRING_VALID(_media->description)) + { + *description = strdup(_media->description); + if(*description == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *description = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_longitude(media_info_h media, double* longitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && longitude) + { + *longitude = _media->longitude; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} +int media_info_get_latitude(media_info_h media, double* latitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && latitude) + { + *latitude = _media->latitude; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_altitude(media_info_h media, double *altitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && altitude) + { + *altitude = _media->altitude; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_rating(media_info_h media, int *rating) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && rating) + { + *rating = _media->rating; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_favorite(media_info_h media, bool* favorite) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && favorite) + { + + *favorite = _media->favourite; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_author(media_info_h media, char **author) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && author) + { + if(STRING_VALID(_media->author)) + { + *author = strdup(_media->author); + if(*author == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *author = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_provider(media_info_h media, char **provider) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && provider) + { + if(STRING_VALID(_media->provider)) + { + *provider = strdup(_media->provider); + if(*provider == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *provider = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_content_name(media_info_h media, char **content_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && content_name) + { + if(STRING_VALID(_media->content_name)) + { + *content_name = strdup(_media->content_name); + if(*content_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *content_name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_category(media_info_h media, char **category) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && category) + { + if(STRING_VALID(_media->category)) + { + *category = strdup(_media->category); + if(*category == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *category = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_location_tag(media_info_h media, char **location_tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && location_tag) + { + if(STRING_VALID(_media->location_tag)) + { + *location_tag = strdup(_media->location_tag); + if(*location_tag == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *location_tag = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_age_rating(media_info_h media, char **age_rating) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && age_rating) + { + if(STRING_VALID(_media->age_rating)) + { + *age_rating = strdup(_media->age_rating); + if(*age_rating == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *age_rating = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_keyword(media_info_h media, char **keyword) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && keyword) + { + if(STRING_VALID(_media->keyword)) + { + *keyword = strdup(_media->keyword); + if(*keyword == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *keyword = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_is_drm(media_info_h media, bool *is_drm) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media) + { + *is_drm = _media->is_drm; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_storage_type(media_info_h media, media_content_storage_e *storage_type) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media && storage_type) + { + *storage_type = _media->storage_type; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_get_media_from_db(const char *media_id, media_info_h *media) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char select_query[DEFAULT_QUERY_SIZE]; + sqlite3_stmt *stmt = NULL; + + if(!STRING_VALID(media_id) || (media == NULL)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_MEDIA_FROM_MEDIA, media_id); + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_info_s *_media = (media_info_s*)calloc(1, sizeof(media_info_s)); + + if(_media == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + SQLITE3_FINALIZE(stmt); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _media_info_item_get_detail(stmt, (media_info_h)_media); + + *media = (media_info_h)_media; + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_info_set_display_name(media_info_h media, const char *display_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL && STRING_VALID(display_name)) + { + SAFE_FREE(_media->display_name); + + _media->display_name = strdup(display_name); + if(_media->display_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_description(media_info_h media, const char *description) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->description); + + if(STRING_VALID(description)) + { + _media->description = strdup(description); + + if(_media->description == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->description = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_longitude(media_info_h media, double longitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + _media->longitude = longitude; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_latitude(media_info_h media, double latitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + _media->latitude = latitude; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_altitude(media_info_h media, double altitude) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + _media->altitude = altitude; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_rating(media_info_h media, int rating) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + _media->rating = rating; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_added_time(media_info_h media, time_t added_time) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_info_s *_media = (media_info_s*)media; + + if((_media != NULL) && (added_time >= 0)) + { + _media->added_time = added_time; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_favorite(media_info_h media, bool favorite) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + _media->favourite = favorite; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_author(media_info_h media, const char *author) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + if(STRING_VALID(author)) + { + _media->author = strdup(author); + if(_media->author == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->author = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_provider(media_info_h media, const char *provider) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->provider); + + if(STRING_VALID(provider)) + { + _media->provider = strdup(provider); + if(_media->provider == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->provider = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_content_name(media_info_h media, const char *content_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->content_name); + + if(STRING_VALID(content_name)) + { + _media->content_name = strdup(content_name); + if(_media->content_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->content_name = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_category(media_info_h media, const char *category) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->category); + + if(STRING_VALID(category)) + { + _media->category = strdup(category); + if(_media->category == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->category = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_location_tag(media_info_h media, const char *location_tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->location_tag); + + if(STRING_VALID(location_tag)) + { + _media->location_tag = strdup(location_tag); + if(_media->location_tag == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->location_tag = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_age_rating(media_info_h media, const char *age_rating) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->age_rating); + + if(STRING_VALID(age_rating)) + { + _media->age_rating = strdup(age_rating); + if(_media->age_rating == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->age_rating = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_set_keyword(media_info_h media, const char *keyword) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_s *_media = (media_info_s*)media; + + if(_media != NULL) + { + SAFE_FREE(_media->keyword); + + if(STRING_VALID(keyword)) + { + _media->keyword = strdup(keyword); + if(_media->keyword == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + _media->keyword = NULL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_update_to_db(media_info_h media) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int len = 0; + media_info_s *_media = (media_info_s*)media; + char *set_sql = NULL; + char sql[MAX_QUERY_SIZE]; + memset(sql, '\0', sizeof(sql)); + + if(_media != NULL && STRING_VALID(_media->media_id)) + { + set_sql = sqlite3_mprintf("file_name=%Q, added_time=%d, description=%Q, longitude=%f, latitude=%f, altitude=%f, \ + rating=%d, favourite=%d, author=%Q, provider=%Q, content_name=%Q, category=%Q, location_tag=%Q, age_rating=%Q, keyword=%Q", + _media->display_name, _media->added_time, _media->description, _media->longitude, _media->latitude, _media->altitude, _media->rating, _media->favourite, + _media->author, _media->provider, _media->content_name, _media->category, _media->location_tag, _media->age_rating, _media->keyword); + + len = snprintf(sql, sizeof(sql), "UPDATE %s SET %s WHERE media_uuid='%s'", DB_TABLE_MEDIA, set_sql, _media->media_id); + sqlite3_free(set_sql); + if (len > 0) { + sql[len] = '\0'; + } else { + media_content_error("snprintf failed"); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _content_query_sql(sql); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_info_refresh_metadata_to_db(const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_info_h media; + char *file_path = NULL; + media_content_type_e media_type = 0; + media_content_storage_e storage_type = 0; + + if(!STRING_VALID(media_id)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = media_info_get_media_from_db(media_id, &media); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = media_info_get_media_type(media, &media_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_info_destroy(media); + return ret; + } + + ret = media_info_get_storage_type(media, &storage_type); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_info_destroy(media); + return ret; + } + + ret = media_info_get_file_path(media, &file_path); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_info_destroy(media); + return ret; + } + + ret = media_svc_refresh_item(_content_get_db_handle(), storage_type, file_path, media_type); + + SAFE_FREE(file_path); + media_info_destroy(media); + + return ret; +} + +int media_info_move_media_to_db(media_info_h media, const char* dst_path) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + int src_storage_type = 0; + int dst_storage_type = 0; + + if(media == NULL || !STRING_VALID(dst_path)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_info_s *_media = (media_info_s*)media; + + ret = _media_util_get_store_type_by_path(_media->file_path, &src_storage_type); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + ret = _media_util_get_store_type_by_path(dst_path, &dst_storage_type); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + ret = media_svc_move_item(_content_get_db_handle(), src_storage_type, _media->file_path, dst_storage_type, dst_path); + return _content_error_capi(MEDIA_CONTENT_TYPE, ret); +} + diff --git a/src/media_playlist.c b/src/media_playlist.c new file mode 100755 index 0000000..39be583 --- /dev/null +++ b/src/media_playlist.c @@ -0,0 +1,652 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_filter.h> +#include <media_info.h> +#include <media_info_private.h> +#include <media_playlist.h> + + +static __thread GList *g_playlist_item_list = NULL; + +static void __media_playlist_item_add(media_playlist_item_s *item_s); +static void __media_playlist_item_release(void); +static int __media_playlist_insert_playlist_record(const char *playlist_name, int *playlist_id); +static int __media_playlist_insert_item_to_playlist(int playlist_id, const char *media_id); +static int __media_playlist_remove_item_from_playlist(int playlist_id, int playlist_member_id); +static int __media_playlist_update_playlist_name(int playlist_id, const char *playlist_name); +static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order); + +static void __media_playlist_item_add(media_playlist_item_s *item_s) +{ + g_playlist_item_list = g_list_append(g_playlist_item_list, item_s); +} + +static void __media_playlist_item_release(void) +{ + int idx = 0; + int list_cnt = 0; + media_playlist_item_s *item = NULL; + + list_cnt = g_list_length(g_playlist_item_list); + + media_content_debug("list_cnt : [%d]", list_cnt); + + for(idx = 0; idx < list_cnt; idx++) + { + item = (media_playlist_item_s*)g_list_nth_data(g_playlist_item_list, idx); + if(item != NULL) + { + SAFE_FREE(item->media_id); + SAFE_FREE(item->playlist_name); + SAFE_FREE(item); + } + } + + g_list_free(g_playlist_item_list); + g_playlist_item_list = NULL; + +} + +static int __media_playlist_insert_playlist_record(const char *playlist_name, int *playlist_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + char *select_query = NULL; + sqlite3_stmt *stmt = NULL; + + query_str = sqlite3_mprintf(INSERT_PLAYLIST_TO_PLAYLIST, playlist_name); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + select_query = sqlite3_mprintf(SELECT_PLAYLIST_ID_FROM_PLAYLIST, playlist_name); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + sqlite3_free(select_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *playlist_id = (int)sqlite3_column_int(stmt,0); + } + + SQLITE3_FINALIZE(stmt); + + return MEDIA_CONTENT_ERROR_NONE; +} + +static int __media_playlist_insert_item_to_playlist(int playlist_id, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + char *query_str = NULL; + int play_order = 0; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_MAX_PLAY_ORDER_FROM_PLAYLIST_VIEW, playlist_id); + + /* get the max play_order */ + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + play_order = (int)sqlite3_column_int(stmt, 0); + } + + SQLITE3_FINALIZE(stmt); + + ++play_order; + + query_str = sqlite3_mprintf("INSERT INTO %q (playlist_id, media_uuid, play_order) values (%d, '%q', %d)", + DB_TABLE_PLAYLIST_MAP, playlist_id, media_id, play_order); + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_playlist_remove_item_from_playlist(int playlist_id, int playlist_member_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf(REMOVE_PLAYLIST_ITEM_FROM_PLAYLIST_MAP, playlist_id, playlist_member_id); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_playlist_update_playlist_name(int playlist_id, const char *playlist_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf(UPDATE_PLAYLIST_NAME_FROM_PLAYLIST, playlist_name, playlist_id); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_playlist_update_play_order(int playlist_id, int playlist_member_id, int play_order) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf(UPDATE_PLAYLIST_ORDER_FROM_PLAYLIST_MAP, play_order, playlist_id, playlist_member_id); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +int media_playlist_insert_to_db(const char *name, media_playlist_h *playlist) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int playlist_id = 0; + + if(!STRING_VALID(name)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s)); + + if(_playlist == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + ret = __media_playlist_insert_playlist_record(name, &playlist_id); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + SAFE_FREE(_playlist); + return ret; + } + + _playlist->playlist_id = playlist_id; + _playlist->name = strdup(name); + + if(_playlist->name == NULL) + { + SAFE_FREE(_playlist); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + *playlist = (media_playlist_h)_playlist; + + return ret; +} + +int media_playlist_delete_from_db(int playlist_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + if(playlist_id < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + query_str = sqlite3_mprintf(DELETE_PLAYLIST_FROM_PLAYLIST, playlist_id); + + ret = _content_query_sql(query_str); + + sqlite3_free(query_str); + + return ret; +} + +int media_playlist_get_playlist_count_from_db(filter_h filter, int *playlist_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(playlist_count != NULL) + { + ret = _media_db_get_group_count(filter, MEDIA_GROUP_PLAYLIST, playlist_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_foreach_playlist_from_db(filter_h filter, media_playlist_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_playlist(filter, callback, user_data); + + return ret; +} + +int media_playlist_get_media_count_from_db(int playlist_id, filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((playlist_id > 0) && (media_count != NULL)) + { + ret = _media_db_get_group_item_count_by_id(playlist_id, filter, MEDIA_GROUP_PLAYLIST, media_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_foreach_media_from_db(int playlist_id, filter_h filter, playlist_member_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((playlist_id > 0) && (callback != NULL)) + { + //ret = _media_db_get_group_item_by_id(playlist_id, filter, callback, user_data, MEDIA_GROUP_PLAYLIST); + ret = _media_db_get_playlist_item(playlist_id, filter, callback, user_data); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_destroy(media_playlist_h playlist) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + media_content_debug_func(); + + if(_playlist) + { + SAFE_FREE(_playlist->name); + SAFE_FREE(_playlist); + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_clone(media_playlist_h *dst, media_playlist_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_src = (media_playlist_s*)src; + + media_content_debug_func(); + + if(_src != NULL) + { + media_playlist_s *_dst = (media_playlist_s*)calloc(1, sizeof(media_playlist_s)); + if(_dst == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _dst->playlist_id = _src->playlist_id; + + if(STRING_VALID(_src->name)) + { + _dst->name = strdup(_src->name); + if(_dst->name == NULL) + { + media_playlist_destroy((media_playlist_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + *dst = (media_playlist_h)_dst; + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_get_playlist_from_db(int playlist_id, filter_h filter, media_playlist_h *playlist) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + + if(playlist_id > 0) + { + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_PLAYLIST_FROM_PLAYLIST, playlist_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_playlist_s *_playlist = (media_playlist_s*)calloc(1, sizeof(media_playlist_s)); + + _playlist->playlist_id = (int)sqlite3_column_int(stmt, 0); + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + _playlist->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + + *playlist = (media_playlist_h)_playlist; + } + + SQLITE3_FINALIZE(stmt); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_get_playlist_id(media_playlist_h playlist, int *playlist_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + if((_playlist != NULL) && (playlist_id != NULL)) + { + *playlist_id = _playlist->playlist_id; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_get_name(media_playlist_h playlist, char **name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + if(_playlist) + { + if(STRING_VALID(_playlist->name)) + { + *name = strdup(_playlist->name); + if(*name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *name = NULL; + } + + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_get_play_order(media_playlist_h playlist, int playlist_member_id, int *play_order) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + int playlist_id = 0; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + + if((_playlist == NULL) || (playlist_member_id < 0) || (play_order == NULL)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + playlist_id = _playlist->playlist_id; + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_PLAY_ORDER_FROM_PLAYLIST_VIEW, playlist_id, playlist_member_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + *play_order = (int)sqlite3_column_int(stmt, 0); + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_playlist_set_name(media_playlist_h playlist, const char *playlist_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + if(_playlist != NULL && STRING_VALID(playlist_name)) + { + SAFE_FREE(_playlist->name); + + media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s)); + + item->playlist_name = strdup(playlist_name); + item->function = MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME; + if(item->playlist_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _playlist->name = strdup(playlist_name); + if(_playlist->name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + __media_playlist_item_add(item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_set_play_order(media_playlist_h playlist, int playlist_member_id, int play_order) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + if((_playlist != NULL) && (playlist_member_id > 0) && (play_order >= 0)) + { + media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s)); + + item->playlist_member_id = playlist_member_id; + item->function = MEDIA_PLAYLIST_UPDATE_PLAY_ORDER; + item->play_order = play_order; + + __media_playlist_item_add(item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_add_media(media_playlist_h playlist, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + if(_playlist != NULL && STRING_VALID(media_id)) + { + media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s)); + + item->media_id = strdup(media_id); + item->function = MEDIA_PLAYLIST_ADD; + + if(item->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + __media_playlist_item_add(item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + + +int media_playlist_remove_media(media_playlist_h playlist, int playlist_member_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + + if((_playlist != NULL) && (playlist_member_id > 0)) + { + media_playlist_item_s *item = (media_playlist_item_s*)calloc(1, sizeof(media_playlist_item_s)); + + item->playlist_member_id = playlist_member_id; + item->function = MEDIA_PLAYLIST_REMOVE; + + __media_playlist_item_add(item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_playlist_update_to_db(media_playlist_h playlist) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_s *_playlist = (media_playlist_s*)playlist; + int idx = 0; + int length = 0; + media_playlist_item_s *_playlist_item = NULL; + + if(_playlist == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + length = g_list_length(g_playlist_item_list); + + for (idx = 0; idx < length; idx++) { + _playlist_item = (media_playlist_item_s*)g_list_nth_data(g_playlist_item_list, idx); + if(_playlist_item != NULL) { + switch(_playlist_item->function) { + case MEDIA_PLAYLIST_ADD: + { + ret = __media_playlist_insert_item_to_playlist(_playlist->playlist_id, _playlist_item->media_id); + } + break; + + case MEDIA_PLAYLIST_REMOVE: + { + ret = __media_playlist_remove_item_from_playlist(_playlist->playlist_id, _playlist_item->playlist_member_id); + } + break; + + case MEDIA_PLAYLIST_UPDATE_PLAYLIST_NAME: + { + ret = __media_playlist_update_playlist_name(_playlist->playlist_id, _playlist_item->playlist_name); + } + break; + + case MEDIA_PLAYLIST_UPDATE_PLAY_ORDER: + { + ret = __media_playlist_update_play_order(_playlist->playlist_id, _playlist_item->playlist_member_id, _playlist_item->play_order); + } + break; + } + } + } + + __media_playlist_item_release(); + + return ret; +} diff --git a/src/media_tag.c b/src/media_tag.c index e2f57c1..bec5271 100644..100755 --- a/src/media_tag.c +++ b/src/media_tag.c @@ -1,538 +1,551 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <media_content.h>
-#include <media_info_private.h>
-#include <audio-svc.h>
-#include <audio-svc-error.h>
-#include <audio-svc-types.h>
-#include <visual-svc-types.h>
-#include <visual-svc.h>
-#include <dlog.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-//extern MediaSvcHandle* db_handle;
-
-
-int media_tag_foreach_tag_from_db(media_tag_filter_h filter, media_tag_cb callback,void* user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char limit_query[MIN_QUERY_SIZE];
- char search_query[DEFAULT_QUERY_SIZE];
- char select_query[DEFAULT_QUERY_SIZE];
- char order_query[MIN_QUERY_SIZE];
-
- sqlite3_stmt *stmt = NULL;
-
-
- media_tag_filter_s* _filter = NULL;
-
-
- if(callback == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- memset(limit_query,0x00,sizeof(limit_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(select_query,0x00,sizeof(select_query));
- memset(order_query,0x00,sizeof(order_query));
-
-
- if(filter != NULL)
- _filter = (media_tag_filter_s*)filter;
- else
- {
- media_tag_filter_create((media_tag_filter_h*)&_filter);
- }
-
-
- snprintf(select_query,sizeof(select_query),"%s", SELECT_TAG_LIST);
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and tag_name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_tag_filter_s*)filter != _filter)
- media_tag_filter_destroy((media_tag_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_TAG_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_TAG_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ID);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_ID,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_tag_filter_s*)filter != _filter)
- media_tag_filter_destroy((media_tag_filter_h)_filter);
-
- if(select_query != NULL)
- {
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
- }
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_tag_s* _tag = (media_tag_s*)calloc(1,sizeof(media_tag_s));
-
- if(_tag == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- memset(_tag,0x00,sizeof(media_tag_s));
- _tag->tag_id = (int)sqlite3_column_int(stmt,0);
- _tag->name= strdup((const char *)sqlite3_column_text(stmt, 1));
- if(callback((media_tag_h)_tag,user_data) == false)
- {
- media_tag_destroy((media_tag_h)_tag);
- break;
- }
- media_tag_destroy((media_tag_h)_tag);
-
- }
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-}
-
-
-
-int media_tag_insert_to_db(const char* tag_name,media_tag_h* tag)
-{
-
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
-
- if(tag_name == NULL || strlen(tag_name) == 0)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- media_tag_s *_tag = (media_tag_s*)calloc(1,sizeof(media_tag_s));
-
- _tag->name = strdup(tag_name);
-
- if(_tag->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- ret = minfo_add_tag(_content_get_db_handle(),NULL,tag_name);
-
- if(ret == MB_SVC_ERROR_NONE)
- {
- *tag = (media_tag_h)_tag;
- }
-
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-
-}
-
-int media_tag_delete_from_db(media_tag_h tag)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- if(tag == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
-
- media_tag_s* _tag = (media_tag_s*)tag;
-
-
- ret = minfo_delete_tag(_content_get_db_handle(), NULL, _tag->name);
-
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-
-}
-
-int media_tag_add_media_to_db(media_tag_h tag,media_info_h media)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
-
- media_tag_s* _tag = (media_tag_s*)tag;
- media_info_s* _item = (media_info_s*)media;
-
- if(_tag == NULL || _item == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(_item->media_type == MEDIA_CONTENT_TYPE_AUDIO)
- {
- LOGE("[%s]_NOT_SUPPORTED_AUDIO(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO);
-
- return MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO;
- }
-
- if(_tag->name == NULL || strlen(_tag->name) == 0)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
-
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = minfo_add_tag(_content_get_db_handle(), _item->item_id,_tag->name);
-
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-
-}
-
-int media_tag_remove_media_from_db(media_tag_h tag,media_info_h media)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- char *query_string = NULL;
-
- media_tag_s* _tag = (media_tag_s*)tag;
- media_info_s* _item = (media_info_s*)media;
- if(_tag == NULL || _item == NULL )
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- if(_item->media_type == MEDIA_CONTENT_TYPE_AUDIO)
- {
- LOGE("[%s]_NOT_SUPPORTED_AUDIO(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO);
- return MEDIA_CONTENT_ERROR_NOT_SUPPORTED_AUDIO;
- }
-
-
- if(_tag->name == NULL || strlen(_tag->name) == 0)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- query_string = sqlite3_mprintf("DELETE FROM visual_tag_map WHERE visual_uuid=%s and tag_name=%d",
- _item->item_id, _tag->name);
-
-
- _content_query_sql(query_string);
-
- sqlite3_free(query_string);
-
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-
-}
-
-
-int media_tag_destroy(media_tag_h tag)
-{
- int ret;
- media_tag_s* _tag = (media_tag_s*)tag;
- if(_tag)
- {
- if(_tag->name)
- {
- free(_tag->name);
- }
-
- free(_tag);
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- return ret;
-
-}
-int media_tag_clone(media_tag_h* dst, media_tag_h src)
-{
- int ret;
- media_tag_s* _src = (media_tag_s*)src;
- media_tag_s* _dst = NULL;
-
-
- if((_src != NULL))
- {
- _dst = (media_tag_s*)calloc(1,sizeof(media_tag_s));
-
- if(_dst == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
-
- _dst->tag_id = _src->tag_id;
-
- if((_src->name != NULL) && (strlen(_src->name) > 0))
- {
- _dst->name = strdup(_src->name);
- if(_dst->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- free(_dst);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- *dst = (media_tag_h)_dst;
- ret = MEDIA_CONTENT_ERROR_NONE;
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-}
-
-int media_tag_get_name(media_tag_h tag, char** name)
-{
- int ret;
- media_tag_s* _tag = (media_tag_s*)tag;
- if(_tag)
- {
- if((_tag->name != NULL) && (strlen(_tag->name) > 0))
- {
- *name = strdup(_tag->name);
- if(*name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
- else
- {
- *name = NULL;
- }
- ret = MEDIA_CONTENT_ERROR_NONE;
-
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- return ret;
-
-}
-int media_tag_update_name_to_db(media_tag_h tag, const char* name)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
-
- media_tag_s* _tag = (media_tag_s*)tag;
- if(_tag == NULL || name == NULL || strlen(name) <= 0)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- ret = minfo_rename_tag(_content_get_db_handle(),_tag->name,name);
-
- if(ret == MB_SVC_ERROR_NONE)
- {
- free(_tag->name);
- _tag->name = strdup(name);
- if(_tag->name == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- }
-
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
-}
-
-int media_tag_foreach_media_from_db(media_tag_h tag,media_info_filter_h filter, media_info_cb callback,void* user_data)
-{
- int ret = MEDIA_CONTENT_ERROR_NONE;
- char* media_id = NULL;
- Mitem *mitem = NULL;
- char select_query[DEFAULT_QUERY_SIZE];
- char search_query[MAX_KEYWORD_SIZE];
- char limit_query[MIN_QUERY_SIZE];
- char order_query[MIN_QUERY_SIZE];
-
- media_tag_filter_s* _filter = NULL;
-
- sqlite3_stmt *stmt = NULL;
-
- memset(select_query,0x00,sizeof(select_query));
- memset(search_query,0x00,sizeof(search_query));
- memset(limit_query,0x00,sizeof(limit_query));
- memset(order_query,0x00,sizeof(order_query));
-
- media_tag_s* _tag = (media_tag_s*)tag;
-
- if(_tag == NULL || callback == NULL)
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
-
- if(filter != NULL)
- _filter = (media_tag_filter_s*)filter;
- else
- {
- media_tag_filter_create((media_tag_filter_h*)&_filter);
- }
-
-
- snprintf(select_query,sizeof(select_query),SELECT_MEDIA_FROM_TAG,_tag->name);
-
-
- if((_filter->keyword != NULL) && strlen(_filter->keyword) > 0)
- {
- if(strlen(_filter->keyword) < sizeof(search_query))
- {
- snprintf(search_query,sizeof(search_query)," and display_name like '%%%s%%'", _filter->keyword);
- }
- else
- {
- LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER);
- if((media_tag_filter_s*)filter != _filter)
- media_tag_filter_destroy((media_tag_filter_h)_filter);
- return MEDIA_CONTENT_ERROR_INVALID_PARAMETER;
- }
- }
- else
- {
- search_query[0] = ' ';
- }
-
-
- snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count);
-
-
-
- if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_DISPLAY_NAME,QUERY_KEYWORD_DESC);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE);
- }
- else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC)
- {
- snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FILED_MODIFIED_DATE,QUERY_KEYWORD_DESC);
- }
-
-
- if((media_tag_filter_s*)filter != _filter)
- media_tag_filter_destroy((media_tag_filter_h)_filter);
-
- ret = _content_query_prepare(&stmt,select_query,NULL,search_query,limit_query,order_query);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- return ret;
-
-
- while( sqlite3_step(stmt) == SQLITE_ROW)
- {
- media_info_s* _item = (media_info_s*)calloc(1,sizeof(media_info_s));
-
- if(_item == NULL)
- {
- LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY);
- return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY;
- }
- memset(_item,0x00,sizeof(media_info_s));
- media_id = (char*)sqlite3_column_text(stmt, 1);
- ret = minfo_get_item_by_id(_content_get_db_handle(),media_id, &mitem);
-
- if(ret < 0)
- {
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
- media_info_destroy((media_info_h)_item);
- return _content_error_capi(MEDIA_CONTENT_TYPE,ret);
- }
- _item->item_id = strdup(media_id);
- _item->file_path = strdup(mitem->file_url);
- _item->display_name = strdup(mitem->display_name);
- _item->thumbnail = strdup(mitem->thumb_url);
- _item->date_modified = mitem->mtime;
- _item->media_type = mitem->type;
- if(callback((media_info_h)_item,user_data) == false)
- {
- media_info_destroy((media_info_h)_item);
- break;
- }
- media_info_destroy((media_info_h)_item);
- }
-
- if(mitem != NULL)
- minfo_destroy_mtype_item(mitem);
- if(stmt != NULL)
- {
- sqlite3_finalize(stmt);
- }
-
- return ret;
-}
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <media_content.h> +#include <media_info_private.h> + + +static __thread GList *g_tag_item_list = NULL; + +static void __media_tag_item_add(media_tag_item_s *item_s); +static void __media_tag_item_release(void); +static int __media_tag_insert_item_to_tag(int tag_id, const char *media_id); +static int __media_tag_remove_item_from_tag(int tag_id, const char *media_id); +static int __media_tag_update_tag_name(int tag_id, const char *tag_name); +static int __media_tag_get_tag_info_from_db(const char *name, media_tag_h tag); + +static void __media_tag_item_add(media_tag_item_s *item_s) +{ + g_tag_item_list = g_list_append(g_tag_item_list, item_s); +} + +static void __media_tag_item_release(void) +{ + int idx = 0; + int list_cnt = 0; + media_tag_item_s *item = NULL; + + list_cnt = g_list_length(g_tag_item_list); + + media_content_debug("list_cnt : [%d]", list_cnt); + + for(idx = 0; idx < list_cnt; idx++) + { + item = (media_tag_item_s*)g_list_nth_data(g_tag_item_list, idx); + if(item != NULL) + { + SAFE_FREE(item->media_id); + SAFE_FREE(item->tag_name); + SAFE_FREE(item); + } + } + + g_list_free(g_tag_item_list); + g_tag_item_list = NULL; + +} + +static int __media_tag_insert_item_to_tag(int tag_id, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf("INSERT INTO %q (tag_id, media_uuid) values (%d, '%q')", + DB_TABLE_TAG_MAP, tag_id, media_id); + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_tag_remove_item_from_tag(int tag_id, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf(REMOVE_TAG_ITEM_FROM_TAG_MAP, tag_id, media_id); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_tag_update_tag_name(int tag_id, const char *tag_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + query_str = sqlite3_mprintf(UPDATE_TAG_NAME_FROM_TAG, tag_name, tag_id); + + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + return ret; +} + +static int __media_tag_get_tag_info_from_db(const char *name, media_tag_h tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char *select_query = NULL; + media_tag_s *_tag = (media_tag_s*)tag; + + if(_tag == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + select_query = sqlite3_mprintf(SELECT_TAG_BY_NAME, name); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + sqlite3_free(select_query); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + _tag->tag_id = (int)sqlite3_column_int(stmt,0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + { + _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + } + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_tag_insert_to_db(const char *tag_name, media_tag_h *tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + if(!STRING_VALID(tag_name)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s)); + if(_tag == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + query_str = sqlite3_mprintf(INSERT_TAG_TO_TAG, tag_name); + ret = _content_query_sql(query_str); + sqlite3_free(query_str); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + { + ret = __media_tag_get_tag_info_from_db(tag_name, (media_tag_h)_tag); + *tag = (media_tag_h)_tag; + } + + return ret; +} + +int media_tag_delete_from_db(int tag_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + char *query_str = NULL; + + if(tag_id < 0) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + query_str = sqlite3_mprintf(DELETE_TAG_FROM_TAG, tag_id); + + ret = _content_query_sql(query_str); + + sqlite3_free(query_str); + + return ret; +} + +int media_tag_get_tag_count_from_db(filter_h filter, int *tag_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(tag_count != NULL) + { + ret = _media_db_get_group_count(filter, MEDIA_GROUP_TAG, tag_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_foreach_tag_from_db (filter_h filter, media_tag_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_tag(NULL, filter, callback, user_data); + + return ret; +} + +int media_tag_get_media_count_from_db(int tag_id, filter_h filter, int *media_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if((tag_id > 0) && (media_count != NULL)) + { + ret = _media_db_get_group_item_count_by_id(tag_id, filter, MEDIA_GROUP_TAG, media_count); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_foreach_media_from_db(int tag_id, filter_h filter, media_info_cb callback, void *user_data) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug_func(); + + if(callback == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + ret = _media_db_get_group_item_by_id(tag_id, filter, callback, user_data, MEDIA_GROUP_TAG); + + return ret; +} + +int media_tag_destroy(media_tag_h tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + if(_tag) + { + SAFE_FREE(_tag->name); + SAFE_FREE(_tag); + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} +int media_tag_clone(media_tag_h *dst, media_tag_h src) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_src = (media_tag_s*)src; + media_tag_s *_dst = NULL; + + if((_src != NULL)) + { + _dst = (media_tag_s*)calloc(1, sizeof(media_tag_s)); + + if(_dst == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _dst->tag_id = _src->tag_id; + + if(STRING_VALID(_src->name)) + { + _dst->name = strdup(_src->name); + if(_dst->name == NULL) + { + SAFE_FREE(_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + *dst = (media_tag_h)_dst; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_get_tag_id(media_tag_h tag, int *tag_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + + if((_tag != NULL) && (tag_id != NULL)) + { + *tag_id = _tag->tag_id; + ret = MEDIA_CONTENT_ERROR_NONE; + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_get_name(media_tag_h tag, char **name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + if(_tag) + { + if(STRING_VALID(_tag->name)) + { + *name = strdup(_tag->name); + if(*name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + else + { + *name = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; + + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_get_tag_from_db(int tag_id, media_tag_h *tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + sqlite3_stmt *stmt = NULL; + char select_query[DEFAULT_QUERY_SIZE]; + + if(tag_id <= 0) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(select_query, 0x00, sizeof(select_query)); + + snprintf(select_query, sizeof(select_query), SELECT_TAG_FROM_TAG, tag_id); + + ret = _content_query_prepare(&stmt, select_query, NULL, NULL); + media_content_retv_if(ret != MEDIA_CONTENT_ERROR_NONE, ret); + + while(sqlite3_step(stmt) == SQLITE_ROW) + { + media_tag_s *_tag = (media_tag_s*)calloc(1, sizeof(media_tag_s)); + + if(_tag == NULL) + { + SQLITE3_FINALIZE(stmt); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _tag->tag_id = (int)sqlite3_column_int(stmt, 0); + + if(STRING_VALID((const char *)sqlite3_column_text(stmt, 1))) + { + _tag->name = strdup((const char *)sqlite3_column_text(stmt, 1)); + } + + *tag = (media_tag_h)_tag; + } + + SQLITE3_FINALIZE(stmt); + + return ret; +} + +int media_tag_add_media(media_tag_h tag, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + + if((_tag != NULL) && STRING_VALID(media_id)) + { + media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s)); + + _item->media_id = strdup(media_id); + _item->function = MEDIA_TAG_ADD; + + if(_item->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + __media_tag_item_add(_item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_remove_media(media_tag_h tag, const char *media_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + + if(_tag != NULL && STRING_VALID(media_id)) + { + media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s)); + + _item->media_id = strdup(media_id); + _item->function = MEDIA_TAG_REMOVE; + + if(_item->media_id == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + __media_tag_item_add(_item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_set_name(media_tag_h tag, char *tag_name) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + + if(_tag != NULL && STRING_VALID(tag_name)) + { + SAFE_FREE(_tag->name); + + media_tag_item_s *_item = (media_tag_item_s*)calloc(1, sizeof(media_tag_item_s)); + + _item->tag_name = strdup(tag_name); + _item->function = MEDIA_TAG_UPDATE_TAG_NAME; + + if(_item->tag_name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + _tag->name = strdup(tag_name); + if(_tag->name == NULL) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + + __media_tag_item_add(_item); + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; +} + +int media_tag_update_to_db(media_tag_h tag) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_s *_tag = (media_tag_s*)tag; + int idx = 0; + int length = 0; + media_tag_item_s *_tag_item = NULL; + + if(_tag == NULL) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + length = g_list_length(g_tag_item_list); + + for (idx = 0; idx < length; idx++) { + _tag_item = (media_tag_item_s*)g_list_nth_data(g_tag_item_list, idx); + if(_tag_item != NULL) { + switch(_tag_item->function) { + case MEDIA_TAG_ADD: + { + ret = __media_tag_insert_item_to_tag(_tag->tag_id, _tag_item->media_id); + } + break; + + case MEDIA_TAG_REMOVE: + { + ret = __media_tag_remove_item_from_tag(_tag->tag_id, _tag_item->media_id); + } + break; + + case MEDIA_TAG_UPDATE_TAG_NAME: + { + ret = __media_tag_update_tag_name(_tag->tag_id, _tag_item->tag_name); + } + break; + } + } + } + + __media_tag_item_release(); + + return ret; +} diff --git a/src/media_util_private.c b/src/media_util_private.c new file mode 100755 index 0000000..7927b01 --- /dev/null +++ b/src/media_util_private.c @@ -0,0 +1,68 @@ +/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <string.h> +#include <sys/stat.h> +#include <media_util_private.h> +#include <media_info_private.h> +#include <media_content_type.h> + + +int _media_util_get_store_type_by_path(const char *path, int *storage_type) +{ + if(STRING_VALID(path)) + { + if(strncmp(path, MEDIA_CONTENT_PATH_PHONE, strlen(MEDIA_CONTENT_PATH_PHONE)) == 0) + { + *storage_type = MEDIA_CONTENT_STORAGE_INTERNAL; + } + else if(strncmp (path, MEDIA_CONTENT_PATH_MMC, strlen(MEDIA_CONTENT_PATH_MMC)) == 0) + { + *storage_type = MEDIA_CONTENT_STORAGE_EXTERNAL; + } + } + else + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +int _media_util_get_file_dir_modified_time(const char *path) +{ + struct stat statbuf; + int fd = 0; + int err = 0; + + if(!STRING_VALID(path)) + { + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + memset(&statbuf, 0, sizeof(struct stat)); + fd = stat(path, &statbuf); + if(fd == -1) { + err = errno; + media_content_error("stat(%s) fails. err[%d]", path, err); + return -1; + } + + return statbuf.st_mtime; +} diff --git a/src/media_video.c b/src/media_video.c index e474edd..e8aa927 100644..100755 --- a/src/media_video.c +++ b/src/media_video.c @@ -11,227 +11,269 @@ * 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. +* limitations under the License. */ + #include <media_content.h> #include <media_info_private.h> -#include <visual-svc-error.h> -#include <visual-svc-types.h> -#include <visual-svc.h> #include <media-svc.h> -#include <dlog.h> - -#ifdef LOG_TAG -#undef LOG_TAG -#endif - -#define LOG_TAG "TIZEN_N_MEDIACONTENT" - -//extern MediaSvcHandle* db_handle; - int video_meta_destroy(video_meta_h video) { - int ret; - video_meta_s* _video = (video_meta_s*)video; + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - if(_video->video_id) - { - free(_video->video_id); - } - - if(_video->album) - { - free(_video->album); - } - if(_video->artist) - { - free(_video->artist); - } - if(_video->title) - { - free(_video->title); - } - if(_video->thumbnail) - { - free(_video->thumbnail); - } - - free(_video); + SAFE_FREE(_video->media_id); + SAFE_FREE(_video->title); + SAFE_FREE(_video->album); + SAFE_FREE(_video->artist); + SAFE_FREE(_video->genre); + SAFE_FREE(_video->composer); + SAFE_FREE(_video->year); + SAFE_FREE(_video->recorded_date); + SAFE_FREE(_video->copyright); + SAFE_FREE(_video->track_num); + SAFE_FREE(_video); + + SAFE_FREE(_video); ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - return ret; + return ret; } -#define DUPLICATE_STRING(destination, src) \ -{ \ - char* tmp = src; \ - if(tmp != NULL && strlen(tmp) > 0) \ - { \ - char* new_str = strdup(tmp); \ - destination = new_str; \ - } \ - else \ - { \ - destination = NULL; \ - } \ -} - -#define DUPLICATE_FIELD(field) DUPLICATE_STRING(_dst->field, _src->field) - - - - -int video_meta_clone( video_meta_h* dst, video_meta_h src) +int video_meta_clone(video_meta_h *dst, video_meta_h src) { - int ret; - video_meta_s* _src; - video_meta_s* _dst; + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_src = (video_meta_s*)src; - if((src != NULL)) + if(_src != NULL) { - _src = (video_meta_s*)src; - _dst = (video_meta_s*)calloc(1,sizeof(video_meta_s)); + video_meta_s *_dst = (video_meta_s*)calloc(1, sizeof(video_meta_s)); + if(_dst == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - - _dst->video_id = strdup(_src->video_id); - _dst->longitude = _src->longitude; - _dst->latitude= _src->latitude; - _dst->time_played = _src->time_played; - _dst->duration = _src->duration; - _dst->width = _src->width; - _dst->height = _src->height; - _dst->orientation = _src->orientation; - _dst->date_taken = _src->date_taken; + if(STRING_VALID(_src->media_id)) + { + _dst->media_id = strdup(_src->media_id); + if(_dst->media_id == NULL) + { + video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } - if(_src->album != NULL) + if(STRING_VALID(_src->title)) { - _dst->album = (char*)strdup(_src->album); + _dst->title = strdup(_src->title); + if(_dst->title == NULL) + { + video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->album)) + { + _dst->album = strdup(_src->album); if(_dst->album == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } } - if(_src->artist != NULL) + + if(STRING_VALID(_src->artist)) { - _dst->artist = (char*)strdup(_src->artist); + _dst->artist = strdup(_src->artist); if(_dst->artist == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } } - if(_src->title != NULL) + + if(STRING_VALID(_src->genre)) { - _dst->title = (char*)strdup(_src->title); - if(_dst->title == NULL) + _dst->genre = strdup(_src->genre); + if(_dst->genre == NULL) + { + video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->composer)) + { + _dst->composer = strdup(_src->composer); + if(_dst->composer == NULL) + { + video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + if(STRING_VALID(_src->year)) + { + _dst->year = strdup(_src->year); + if(_dst->year == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } } - if(_src->description != NULL) + + if(STRING_VALID(_src->recorded_date)) { - _dst->description = (char*)strdup(_src->description); - if(_dst->description == NULL) + _dst->recorded_date = strdup(_src->recorded_date); + if(_dst->recorded_date == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - } - if(_src->thumbnail != NULL) + } + + if(STRING_VALID(_src->copyright)) { - _dst->thumbnail = (char*)strdup(_src->thumbnail); - if(_dst->thumbnail == NULL) + _dst->copyright = strdup(_src->copyright); + if(_dst->copyright == NULL) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - } - *dst =(video_meta_h)_dst; + } + + if(STRING_VALID(_src->track_num)) + { + _dst->track_num = strdup(_src->track_num); + if(_dst->track_num == NULL) + { + video_meta_destroy((video_meta_h)_dst); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + + _dst->bitrate = _src->bitrate; + _dst->duration = _src->duration; + _dst->width = _src->width; + _dst->height = _src->height; + _dst->played_count = _src->played_count; + _dst->played_time = _src->played_time; + _dst->played_position = _src->played_position; + + *dst = (video_meta_h)_dst; + ret = MEDIA_CONTENT_ERROR_NONE; - } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - - } - -int video_meta_get_longitude(video_meta_h video, double* longitude) +int video_meta_get_media_id(video_meta_h video, char **media_id) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && longitude) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - *longitude = _video->longitude; + if(STRING_VALID(_video->media_id)) + { + char *new_string = strdup(_video->media_id); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *media_id = new_string; + } + else + { + *media_id = NULL; + } ret = MEDIA_CONTENT_ERROR_NONE; + } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; } -int video_meta_get_latitude(video_meta_h video, double* latitude) + +int video_meta_get_title(video_meta_h video, char **title) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && latitude) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - *latitude = _video->latitude; + if(STRING_VALID(_video->title)) + { + char *new_string = strdup(_video->title); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *title = new_string; + } + else + { + *title = NULL; + } ret = MEDIA_CONTENT_ERROR_NONE; + } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_album(video_meta_h video, char** album) +int video_meta_get_album(video_meta_h video, char **album) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - if((_video->album != NULL) && (strlen(_video->album) > 0)) + if(STRING_VALID(_video->album)) { - char* new_string = strdup(_video->album); + char *new_string = strdup(_video->album); if(NULL == new_string) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } *album = new_string; @@ -240,30 +282,30 @@ int video_meta_get_album(video_meta_h video, char** album) { *album = NULL; } - ret = MEDIA_CONTENT_ERROR_NONE; + ret = MEDIA_CONTENT_ERROR_NONE; } - else + else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + } return ret; } -int video_meta_get_artist(video_meta_h video, char** artist) +int video_meta_get_artist(video_meta_h video, char **artist) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - if((_video->artist != NULL) && (strlen(_video->artist) > 0)) + if(STRING_VALID(_video->artist)) { - char* new_string = strdup(_video->artist); + char *new_string = strdup(_video->artist); if(NULL == new_string) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } *artist = new_string; @@ -272,471 +314,414 @@ int video_meta_get_artist(video_meta_h video, char** artist) { *artist = NULL; } - ret = MEDIA_CONTENT_ERROR_NONE; + ret = MEDIA_CONTENT_ERROR_NONE; } - else + else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + } return ret; } -int video_meta_get_title(video_meta_h video, char** title) + +int video_meta_get_genre(video_meta_h video, char **genre) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - if((_video->title != NULL) && (strlen(_video->title) > 0)) + if(STRING_VALID(_video->genre)) { - char* new_string = strdup(_video->title); + char *new_string = strdup(_video->genre); if(NULL == new_string) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - *title = new_string; + *genre = new_string; } else { - *title = NULL; + *genre = NULL; } - ret = MEDIA_CONTENT_ERROR_NONE; + ret = MEDIA_CONTENT_ERROR_NONE; } - else + else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + } return ret; - } -int video_meta_get_description(video_meta_h video, char** description) + +int video_meta_get_composer(video_meta_h video, char **composer) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - if((_video->description != NULL) && (strlen(_video->description) > 0)) + if(STRING_VALID(_video->composer)) { - char* new_string = strdup(_video->description); + char *new_string = strdup(_video->composer); if(NULL == new_string) { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; } - *description = new_string; + *composer = new_string; } else { - *description = NULL; + *composer = NULL; } - ret = MEDIA_CONTENT_ERROR_NONE; + ret = MEDIA_CONTENT_ERROR_NONE; } - else + else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; - } + } return ret; - } - -int video_meta_get_time_played(video_meta_h video, int* time_played) +int video_meta_get_year(video_meta_h video, char **year) { - int ret; - video_meta_s* _video = (video_meta_s*)video; + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; if(_video) { - *time_played = _video->time_played; + if(STRING_VALID(_video->year)) + { + char *new_string = strdup(_video->year); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *year = new_string; + } + else + { + *year = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_duration(video_meta_h video, int* duration) + +int video_meta_get_recorded_date(video_meta_h video, char **recorded_date) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && duration) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - *duration = _video->duration; + if(STRING_VALID(_video->recorded_date)) + { + char *new_string = strdup(_video->recorded_date); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *recorded_date = new_string; + } + else + { + *recorded_date = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_width(video_meta_h video, int* width) + +int video_meta_get_copyright(video_meta_h video, char **copyright) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && width) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - *width = _video->width; + if(STRING_VALID(_video->copyright)) + { + char *new_string = strdup(_video->copyright); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *copyright = new_string; + } + else + { + *copyright = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_height(video_meta_h video, int* height) + +int video_meta_get_track_num(video_meta_h video, char **track_num) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && height) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) { - *height = _video->height; + if(STRING_VALID(_video->track_num)) + { + char *new_string = strdup(_video->track_num); + if(NULL == new_string) + { + media_content_error("OUT_OF_MEMORY(0x%08x)", MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *track_num = new_string; + } + else + { + *track_num = NULL; + } + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_orientation(video_meta_h video, media_content_orientation_e* orientation) + +int video_meta_get_bit_rate(video_meta_h video, int *bit_rate) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && orientation) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + + if(_video && bit_rate) { - *orientation = _video->orientation; + *bit_rate = _video->bitrate; ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_get_date_taken(video_meta_h video, time_t* date_taken) + +int video_meta_get_duration(video_meta_h video, int *duration) { - int ret; - video_meta_s* _video = (video_meta_s*)video; - if(_video && date_taken) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + + if(_video && duration) { - *date_taken = _video->date_taken; + *duration = _video->duration; ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_meta_update_time_played_to_db(video_meta_h video, int time_played) +int video_meta_get_width(video_meta_h video, int *width) { int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; - video_meta_s* _video = (video_meta_s*)video; - - if(_video != NULL ) + if(_video && width) { - ret = minfo_update_video_meta_info_int(_content_get_db_handle(),_video->video_id,MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED,time_played); - ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret); + *width = _video->width; + ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - return ret; - } - - -int video_bookmark_foreach_bookmark_from_db(video_meta_h video,video_bookmark_filter_h filter, video_bookmark_cb callback,void* user_data) +int video_meta_get_height(video_meta_h video, int *height) { int ret = MEDIA_CONTENT_ERROR_NONE; - char limit_query[MIN_QUERY_SIZE]; - char order_query[MIN_QUERY_SIZE]; - char select_query[DEFAULT_QUERY_SIZE]; - - sqlite3_stmt *stmt = NULL; - - - video_bookmark_filter_s* _filter = NULL; - - video_meta_s* _video = (video_meta_s*)video; - - - if(_video == NULL || callback == NULL) + video_meta_s *_video = (video_meta_s*)video; + if(_video && height) { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + *height = _video->height; + ret = MEDIA_CONTENT_ERROR_NONE; } - - memset(order_query,0x00,sizeof(order_query)); - memset(limit_query,0x00,sizeof(limit_query)); - memset(select_query,0x00,sizeof(select_query)); - - - if(filter != NULL) - _filter = (video_bookmark_filter_s*)filter; else { - video_bookmark_filter_create((video_bookmark_filter_h*)&_filter); - } - - - snprintf(select_query,sizeof(select_query), SELECT_BOOKMARK_FROM_VIDEO,_video->video_id); - - snprintf(limit_query,sizeof(limit_query),"%s %d,%d",QUERY_KEYWORD_LIMIT,_filter->offset,_filter->count); - - - if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_ASC) - { - snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_THUMBNAIL_PATH); - } - else if(_filter->order == MEDIA_CONTENT_SORT_BY_NAME_DESC) - { - snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_THUMBNAIL_PATH,QUERY_KEYWORD_DESC); - } - else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_ASC) - { - snprintf(order_query,sizeof(order_query),"%s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_MARKED_TIME); - } - else if(_filter->order == MEDIA_CONTENT_SORT_BY_DATE_DESC) - { - snprintf(order_query,sizeof(order_query),"%s %s %s",QUERY_KEYWORD_ORDER_BY,DB_FIELD_MARKED_TIME,QUERY_KEYWORD_DESC); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - if((video_bookmark_filter_s*)filter != _filter) - video_bookmark_filter_destroy((video_bookmark_filter_h)_filter); - - ret = _content_query_prepare(&stmt,select_query,NULL,NULL,limit_query,order_query); - - if(ret != MEDIA_CONTENT_ERROR_NONE) - return ret; + return ret; +} +int video_meta_get_played_count(video_meta_h video, int *played_count) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; - while( sqlite3_step(stmt) == SQLITE_ROW) + if(_video && played_count) { - video_bookmark_s* bookmark = (video_bookmark_s*)calloc(1,sizeof(video_bookmark_s)); - if(bookmark == NULL) - { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - - bookmark->bookmark_id= (int)sqlite3_column_int(stmt,0); - bookmark->video_id= strdup((const char *)sqlite3_column_text(stmt, 1)); - bookmark->time_marked = (int)sqlite3_column_int(stmt,2); - bookmark->thumbnail= strdup((const char *)sqlite3_column_text(stmt, 3)); - if(callback((video_bookmark_h)bookmark,user_data) == false) - { - video_bookmark_destroy((video_bookmark_h)bookmark); - break; - } - video_bookmark_destroy((video_bookmark_h)bookmark); + *played_count = _video->played_count; + ret = MEDIA_CONTENT_ERROR_NONE; } - if(stmt != NULL) + else { - sqlite3_finalize(stmt); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - - - } - -int video_bookmark_destroy(video_bookmark_h bookmark) +int video_meta_get_played_time(video_meta_h video, time_t* played_time) { - int ret; - video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; - if(_bookmark) - { - if(_bookmark->video_id!= NULL) - free(_bookmark->video_id); - if(_bookmark->thumbnail != NULL) - free(_bookmark->thumbnail); - free(_bookmark); + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + + if(_video) + { + *played_time = _video->played_time; ret = MEDIA_CONTENT_ERROR_NONE; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } - return ret; + return ret; } -int video_bookmark_clone(video_bookmark_h* dst, video_bookmark_h src) + +int video_meta_get_played_position(video_meta_h video, int *played_position) { - int ret; - - if((src != NULL)) - { - video_bookmark_s* _src = (video_bookmark_s*)src; - video_bookmark_s* _dst = (video_bookmark_s*)calloc(1,sizeof(video_bookmark_s)); - if (NULL == _dst) - { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - _dst->bookmark_id = _src->bookmark_id; - _dst->video_id = strdup(_src->video_id); - _dst->time_marked= _src->time_marked; - - if(_src->thumbnail != NULL) - { - _dst->thumbnail = (char*)strdup(_src->thumbnail); - if(_dst->thumbnail == NULL) - { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - video_bookmark_destroy((video_bookmark_h)_dst); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video) + { + *played_position = _video->played_position; ret = MEDIA_CONTENT_ERROR_NONE; - *dst = (video_bookmark_h)_dst; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_bookmark_get_time_marked(video_bookmark_h bookmark, time_t* time_marked) +int video_meta_set_played_count(video_meta_h video, int played_count) { - int ret; - video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; - if(_bookmark ) + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + + if(_video != NULL) { - *time_marked = _bookmark->time_marked; - ret = MEDIA_CONTENT_ERROR_NONE; + _video->played_count = played_count; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_bookmark_get_thumbnail_path(video_bookmark_h bookmark, char** thumbnail) + +int video_meta_set_played_time(video_meta_h video, time_t played_time) { - int ret; - video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; - if(_bookmark) - { - if((_bookmark->thumbnail != NULL) && (strlen(_bookmark->thumbnail) > 0)) - { - *thumbnail = strdup(_bookmark->thumbnail); - if (NULL == *thumbnail) - { - LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); - return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; - } - } - else - { - *thumbnail = NULL; - } - ret = MEDIA_CONTENT_ERROR_NONE; + int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + if(_video != NULL) + { + _video->played_time = played_time; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } - - - -int video_bookmark_insert_to_db(video_meta_h video, time_t time, const char* thumbnail_path) +int video_meta_set_played_position(video_meta_h video, int played_position) { int ret = MEDIA_CONTENT_ERROR_NONE; - - video_meta_s* _video = (video_meta_s*)video; + video_meta_s *_video = (video_meta_s*)video; if(_video != NULL) { - ret = minfo_add_bookmark(_content_get_db_handle(),_video->video_id,time,thumbnail_path); - ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret); + _video->played_position = played_position; } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - - return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } -int video_bookmark_delete_from_db(video_bookmark_h bookmark) + +int video_meta_update_to_db(video_meta_h video) { int ret = MEDIA_CONTENT_ERROR_NONE; + video_meta_s *_video = (video_meta_s*)video; + char *sql = NULL; - video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; - - if( _bookmark != NULL) + if(_video != NULL && STRING_VALID(_video->media_id)) { - ret = minfo_delete_bookmark(_content_get_db_handle(),_bookmark->bookmark_id); - ret = _content_error_capi(MEDIA_CONTENT_TYPE,ret); + sql = sqlite3_mprintf(UPDATE_AV_META_FROM_MEDIA, _video->played_count, _video->played_time, _video->played_position, _video->media_id); + ret = _content_query_sql(sql); + sqlite3_free(sql); } else { - LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_INVALID_PARAMETER); - return MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + media_content_error("INVALID_PARAMETER(0x%08x)", MEDIA_CONTENT_ERROR_INVALID_PARAMETER); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; } return ret; - } - - - diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index fc8f5f6..7097377 100755 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -2,7 +2,7 @@ SET(fw_name "capi-content-media-content") SET(fw_test "${fw_name}-test") INCLUDE(FindPkgConfig) -pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-service drm-service aul capi-base-common) +pkg_check_modules(${fw_test} REQUIRED glib-2.0 dlog libmedia-service capi-base-common libmedia-utils) FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) diff --git a/test/media-content_test.c b/test/media-content_test.c index 7fc041c..1da6157 100644..100755 --- a/test/media-content_test.c +++ b/test/media-content_test.c @@ -1,699 +1,2039 @@ -/*
-* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved
-*
-* 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 <stdio.h>
-#include <stdlib.h>
-#include <media_content.h>
-#include <dlog.h>
-#include <pthread.h>
-
-#ifdef LOG_TAG
-#undef LOG_TAG
-#endif
-#define LOG_TAG "TIZEN_N_MEDIACONTENT"
-
-
-int test_content_connect_database()
-{
- int ret;
-
- LOGI("\n============DB Connection Test============\n\n");
-
- ret = media_content_connect();
-
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- {
- LOGI("connection is success\n\n");
- }
- else
- LOGE("connection is failed\n\n");
-
- return ret;
-}
-
-void test_content_disconnect_database()
-{
-
- int ret;
- LOGI("\n============DB Disconnection Test============\n\n");
-
- ret = media_content_disconnect();
-
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- LOGI("disconnection is success\n\n");
- else
- LOGE("disconnection is failed\n\n");
-
-}
-
-bool capi_media_list_cb(media_info_h item, void *user_data)
-{
- int ret = true;
-
- char* file_path = NULL;
-
- char* name = NULL;
- char* thumbnail_path = NULL;
- time_t date_modified;
- int type;
-
- if(item != NULL)
- {
- if(media_info_get_file_path(item,&file_path) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_get_file_path is failed\n");
- ret = false;
- }
-
- if(media_info_get_display_name(item,&name) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_get_display_name is failed\n");
- ret = false;
- }
- if(media_info_get_thumbnail_path(item,&thumbnail_path) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_get_thumbnail_path is failed\n");
- ret = false;
- }
- if(media_info_get_date_modified(item,&date_modified) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_get_date_modified is failed\n");
- ret = false;
- }
- if(media_info_get_media_type(item,&type) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_get_content_type is failed\n");
- ret = false;
- }
- LOGI("[%d] name : %s , file path : %s , date : %s , thumbnail path : %s \n"
- ,type,name,file_path,ctime(&date_modified),thumbnail_path);
-
-
-
-
- if(type == MEDIA_CONTENT_TYPE_IMAGE)
- {
- image_meta_h image;
-
- double lati;
- double longi;
-
- if(media_info_get_image_from_db(item,&image) == MEDIA_CONTENT_ERROR_NONE)
- {
- image_meta_get_latitude(image,&lati);
- image_meta_get_longitude(image,&longi);
- //printf("[image] latitude : %f , longitude : %f \n",lati, longi);
-
- image_meta_destroy(image);
- }
- else
- LOGE("[image_error] \n");
-
- }
- if(type == MEDIA_CONTENT_TYPE_VIDEO)
- {
- video_meta_h video;
- double lati;
- double longi;
-
- if(media_info_get_video_from_db(item,&video) == MEDIA_CONTENT_ERROR_NONE)
- {
- video_meta_get_latitude(video,&lati);
- video_meta_get_longitude(video,&longi);
- video_meta_destroy(video);
- }
- else
- LOGE("[video_error] \n");
-
- }
- if(type == MEDIA_CONTENT_TYPE_AUDIO)
- {
- audio_meta_h audio;
-
- if(media_info_get_audio_from_db(item,&audio) == MEDIA_CONTENT_ERROR_NONE)
- {
-
- audio_meta_destroy(audio);
- }
- else
- LOGE("[audio_error] \n");
-
- }
-
-
- if(file_path != NULL)
- free(file_path);
- if(name != NULL)
- free(name);
- if(thumbnail_path != NULL)
- free(thumbnail_path);
-
- }
-
- return ret;
-}
-
-bool capi_folder_list_cb(media_folder_h folder, void* user_data)
-{
- int item_count;
- char* folder_path;
- char* folder_name;
- media_content_storage_e storage_type;
- bool ret;
- media_folder_h* _folder = (media_folder_h*)user_data;
-
- if(folder != NULL)
- {
- media_folder_clone(_folder,folder);
-
- if(media_folder_get_path(folder,&folder_path) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_get_path is failed\n");
- ret = false;
- }
- if(media_folder_get_name(folder,&folder_name) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_get_name is failed\n");
- ret = false;
- }
- if(media_folder_get_storage_type(folder,&storage_type) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_get_storage_type is failed\n");
- ret = false;
- }
- if(media_folder_get_media_count_from_db(folder,MEDIA_CONTENT_TYPE_IMAGE|MEDIA_CONTENT_TYPE_VIDEO|MEDIA_CONTENT_TYPE_AUDIO,&item_count) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_get_media_count_from_db is failed\n");
- ret = false;
- }
- LOGI("[name : %s] media count : %d , storage type : %d, path : %s \n",
- folder_name,item_count,storage_type,folder_path);
-
- if(folder_path != NULL)
- {
- free(folder_path);
- }
- if(folder_name != NULL)
- {
- free(folder_name);
- }
-
- //media_folder_destroy(_folder);
- ret = true;
- }
- else
- {
- ret = false;
- }
-
- return ret;
-}
-
-
-bool capi_audio_list_cb(audio_album_h album,void* user_data)
-{
- int ret;
- char* name = NULL;
-
- if(album != NULL)
- {
- if(audio_album_get_name(album,&name) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] audio_album_get_name is failed\n");
- ret = false;
- }
-
- if(name != NULL)
- {
- LOGE("album is found : %s \n",name);
- free(name);
- }
-
-
- }
- else
- ret = false;
-
- return ret;
-}
-
-
-
-void test_folder_foreach_from_db()
-{
- int ret;
- media_folder_h folder;
-
-
- //test.1 set the filter
- media_folder_filter_h filter; // handle of filter
-
- if(media_folder_filter_create(&filter) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_filter_create is failed\n");
- return ;
- }
- //test.2 get the folder
- ret = media_folder_foreach_folder_from_db(filter, capi_folder_list_cb,&folder);
-
- //test.3 get the media list in first folder
- media_info_filter_h m_filter = NULL;
- if(media_info_filter_create(&m_filter) != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_info_filter_create is failed\n");
- return ;
-
- }
- media_info_filter_set_media_type(m_filter,MEDIA_CONTENT_TYPE_IMAGE);
- media_info_filter_set_offset(m_filter,1,5);
- media_info_filter_set_search_keyword(m_filter,MEDIA_INFO_SEARCH_BY_DISPLAY_NAME,"ph");
- media_info_filter_set_order(m_filter,MEDIA_CONTENT_SORT_BY_NAME_DESC);
-
- ret = media_folder_foreach_media_from_db(folder,m_filter, capi_media_list_cb,NULL);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d\n",ret);
- }
-
- media_folder_filter_destroy(filter);
- media_info_filter_destroy(m_filter);
-
-}
-
-
-void test_media_info_foreach_from_db()
-{
- int ret;
- LOGI("\n============Content get Media Test============\n\n");
-
- //test4-1. get all items
- media_info_filter_h filter;
-
-
- media_info_filter_create(&filter);
-
- ret = media_info_foreach_media_from_db(filter, capi_media_list_cb,NULL);
-
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- LOGI("media_info_foreach_media_from_db is success\n\n");
- else
- LOGE("media_info_foreach_media_from_db is failed\n\n");
-
-
- media_info_filter_destroy(filter);
-}
-
-
-void test_audio_album_foreach_from_db()
-{
- int ret;
- media_audio_filter_h filter = NULL;
-
- media_audio_filter_create(&filter);
-
- ret = audio_album_foreach_album_from_db(filter,capi_audio_list_cb,NULL);
-
- if(ret == MEDIA_CONTENT_ERROR_NONE)
- LOGI("audio_album_foreach_album_from_db is success\n\n");
- else
- LOGE("audio_album_foreach_album_from_db is failed\n\n");
-
-
- if(filter != NULL)
- media_audio_filter_destroy(filter);
-
-
-}
-
-
-bool capi_find_media_cb(media_info_h item,void* user_data)
-{
- media_info_h* _item = (media_info_h*)user_data;
- if(item != NULL)
- {
- char* name = NULL;
- media_info_get_display_name(item,&name);
-
- LOGI("[media]display name : %s \n",name);
-
- if(name != NULL)
- free(name);
- media_info_clone(_item,item);
- }
- return false;
-}
-
-bool capi_taginfo_cb(media_tag_h tag, void* user_data)
-{
- char* tag_name;
- media_tag_h* _tag = (media_tag_h*)user_data;
- if(tag != NULL)
- {
- media_tag_get_name(tag,&tag_name);
- LOGI("[tag name] : %s \n",tag_name);
- media_tag_clone(_tag,tag);
-
- if(tag_name != NULL)
- free(tag_name);
- }
- return false;
-}
-
-
-void test_tag_operation()
-{
-
- //test . insert tag information
- //condition : item is needed to insert the tag, tag is not support for audio
- media_tag_h tag = NULL;
- media_info_h item = NULL;
- media_info_filter_h media_filter = NULL;
- media_info_filter_create(&media_filter);
-
- //find the item which display_name is "1_photo.jpg"
- media_info_foreach_media_from_db(media_filter,capi_find_media_cb,(void *)&item);
- if(media_filter != NULL)
- media_info_filter_destroy(media_filter);
-
- if(item != NULL)
- {
- //insert tag
- media_tag_insert_to_db("test_tag",&tag);
-
-
-
- //add the media to tag.
- media_tag_add_media_to_db(tag,item);
-
-
- //delete the tag
- if(tag != NULL)
- {
- media_tag_delete_from_db(tag);
- media_tag_destroy(tag);
-
- }
-
- media_info_destroy(item);
- }
-
-
-}
-
-
-
-bool capi_get_video_cb(media_info_h item, void* user_data)
-{
- video_meta_h* _video = (video_meta_h*)user_data;
- char* name = NULL;
- if(item != NULL)
- {
- media_info_get_display_name(item,&name);
- LOGI(" video name : %s \n" , name);
-
- media_info_get_video_from_db(item,_video);
-
-
- if(name != NULL)
- free(name);
-
- }
- return false;
-}
-
-bool capi_get_bookmarks_cb(video_bookmark_h bookmark,void* user_data)
-{
- //get the first bookmark.
- // it is needed array of bookmark, if user wan to get list of bookmarks.
- video_bookmark_h* _bookmark = (video_bookmark_h*)user_data;
- if(bookmark != NULL)
- {
- char* name = NULL;
- video_bookmark_get_thumbnail_path(bookmark,&name);
-
- video_bookmark_clone(_bookmark,bookmark);
-
- if(name != NULL)
- {
- LOGI("deleted the bookmark path : %s \n",name);
-
- free(name);
- }
- }
- return false;
-}
-
-void test_video_bookmark_operation()
-{
- //bookmark is only supported for video information.
- video_meta_h video = NULL;
- media_info_filter_h media_filter = NULL;
-
-
- media_info_filter_create(&media_filter);
- media_info_filter_set_media_type(media_filter,MEDIA_CONTENT_TYPE_VIDEO);
-
- //get the media_info which is returned first , and get the video's instance from media_info.
- media_info_foreach_media_from_db(media_filter,capi_get_video_cb,(void *)&video);
-
- media_info_filter_destroy(media_filter);
-
-
- if(video != NULL)
- {
-
- video_bookmark_h bookmark = NULL;
-
- //insert bookmark to video
- char* thumbnail_path1 = "/opt/media/Images and videos/My video clips/teat11.jpg";
- video_bookmark_insert_to_db(video, 200,thumbnail_path1);
-
- //get the bookmark
- video_bookmark_filter_h bookmark_filter = NULL;
- video_bookmark_filter_create(&bookmark_filter);
-
- video_bookmark_foreach_bookmark_from_db(video,bookmark_filter,capi_get_bookmarks_cb,(void*)&bookmark);
-
- video_bookmark_filter_destroy(bookmark_filter);
-
- if(bookmark != NULL)
- {
- video_bookmark_delete_from_db(bookmark);
- }
-
- video_bookmark_destroy(bookmark);
-
-
-
- }
-
- video_meta_destroy(video);
-
-}
-
-
-#include <time.h>
-#include <memory.h>
-void test_insert_item(int count)
-{
- int i =0,ret;
- char img_path[1024];
-
- clock_t start, end;
-
- start = clock();
- for(i =0 ; i< count; i++)
- {
- memset(img_path, 0x00, sizeof(img_path));
- snprintf(img_path,sizeof(img_path),"%s%d.jpg","/opt/media/Images and videos/My photo clips/a",i+0);
-
- ret = media_info_insert_to_db(MEDIA_CONTENT_TYPE_IMAGE,img_path);
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE(" image insert error \n");
- }
- }
- end = clock();
- LOGI(" time : %f \n",(double)(end-start)/CLOCKS_PER_SEC);
-
-
-}
-
-void test_filter_operation()
-{
- int ret;
- int media_type;
- int offset;
- int count;
- char *keyword= NULL;
- media_info_search_type_e search_type;
-
-
- media_info_filter_h filter;
- media_info_filter_create(&filter);
-
- media_info_filter_get_offset( filter,&offset,&count);
- media_info_filter_get_media_type( filter, &media_type);
- media_info_filter_get_search_keyword( filter,&search_type,&keyword);
-
- LOGI("1. media : %d , offset : %d / %d , search : %d / %s \n",media_type, offset,count,search_type,keyword);
-
- ret = media_info_filter_set_search_keyword(filter,MEDIA_INFO_SEARCH_BY_DISPLAY_NAME,"test");
- media_info_filter_get_search_keyword( filter,&search_type,&keyword);
- LOGI("2. media : %d , offset : %d / %d , search : %d / %s ret : %d\n",media_type, offset,count,search_type,keyword, ret);
-
- ret = media_info_filter_set_search_keyword(filter,MEDIA_INFO_SEARCH_NONE,NULL);
- media_info_filter_get_search_keyword( filter,&search_type,&keyword);
- LOGI("3. media : %d , offset : %d / %d , search : %d /%s ret : %d\n",media_type, offset,count,search_type,keyword, ret);
-
-}
-
-bool capi_audio_playlist_cb(audio_playlist_h playlist, void *user_data)
-{
- char* playlist_name = NULL;
- if(playlist != NULL)
- {
- audio_playlist_get_name(playlist,&playlist_name);
-
- if(playlist_name != NULL)
- {
- LOGI(" Playlist Name : %s \n", playlist_name);
- free(playlist_name);
- }
-
- }
- return true;
-}
-
-bool capi_audio_info_cb(media_info_h media,void* user_data)
-{
-
- media_info_h* add_media = (media_info_h*)user_data;
- if(media != NULL)
- {
- media_info_clone(add_media,media);
- }
-
- return false;
-}
-
-bool capi_media_info_in_playlist_cb(media_info_h media,void* user_data)
-{
-
- char* media_name = NULL;
-
- if(media != NULL)
- {
- media_info_get_display_name(media,&media_name);
-
- if(media_name != NULL)
- {
- LOGI("[Playlist] Media Name : %s \n",media_name);
- free(media_name);
- }
- }
- return true;
-}
-
-void test_playlist_operation()
-{
- //1. insert the playlist
- audio_playlist_h playlist;
- char *playlist_name = "myPlaylist";
- int ret = audio_playlist_insert_to_db(playlist_name, &playlist);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] Insert operation is failed\n");
- }
-
- //2. get the playlist using foreach function.
- // if filter is NULL, all item will be retrieved.
- audio_playlist_foreach_playlist_from_db(NULL,capi_audio_playlist_cb,NULL);
-
-
- //3. add the audio to playlist
- media_info_h audio_info = NULL;
- media_info_filter_h media_filter;
- media_info_filter_create(&media_filter);
- media_info_filter_set_media_type(media_filter,MEDIA_CONTENT_TYPE_AUDIO);
- media_info_foreach_media_from_db(media_filter,capi_audio_info_cb,&audio_info);
-
- ret = audio_playlist_add_media_to_db(playlist,audio_info);
-
- media_info_destroy(audio_info);
-
- //4. get the media from playlist
- audio_playlist_foreach_media_from_db(playlist,NULL,capi_media_info_in_playlist_cb,NULL);
-
- //5. deletes the playlist
- ret = audio_playlist_delete_from_db(playlist);
-
- if(ret != MEDIA_CONTENT_ERROR_NONE)
- {
- LOGE("[ERROR] Delete operation is failed\n");
- }
-
-}
-
-int main(int argc, char *argv[])
-{
-
- LOGI("--- content manager test start ---\n\n");
-
- //scenario 1. DB connection
- if(test_content_connect_database() != MEDIA_CONTENT_ERROR_NONE)
- return MEDIA_CONTENT_ERROR_NONE;
-
-
- //scenario 2-1 .1 set the filter
- // .2 gets the folders
- test_folder_foreach_from_db();
-
- //test_insert_item(1000);
- //scenario 2-2. gets the media
- test_media_info_foreach_from_db();
-
- //scenario 2-3. searching the data by filter.
- test_audio_album_foreach_from_db();
-
- //scenario 3. operation of tag information
- // 1. insert the tag
- // 2. get the tag list
- // 3. delete the tag
- test_tag_operation();
-
-
- //scenario 4. the operation of bookmark
- // 1. insert the bookmark
- // 2. get the bookmark list
- // 3. delete the bookmark
- test_video_bookmark_operation();
-
- //scenario 5. the operation of playlist
- test_playlist_operation();
-
-
- //scenario 6. DB disconnection
- test_content_disconnect_database();
- return 0;
-
-}
-
-
-
+/* +* Copyright (c) 2011 Samsung Electronics Co., Ltd All Rights Reserved +* +* 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 <sys/time.h> +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <media_content.h> +#include <media_info_private.h> +#include <dlog.h> +#include <pthread.h> +#include <glib.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "TIZEN_N_MEDIACONTENT" + +filter_h g_filter = NULL; +filter_h g_filter_g = NULL; //filter for group like folder, tag, playlist, album, year ... + + +#define test_audio_id "0f999626-6218-450c-a4ad-181a3bab6ebf" +#define test_video_id "c1a92494-cc5b-4d74-aa7d-253199234548" +#define test_image_id "db1c184c-6f31-43b4-b924-8c00ac5b6197" + +bool get_audio_meta(audio_meta_h audio) +{ + char *c_value = NULL; + int i_value = 0; + time_t t_value = 0; + + media_content_debug("=== audio meta === \n"); + + audio_meta_get_media_id(audio, &c_value); + media_content_debug("audio_id : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_title(audio, &c_value); + media_content_debug("title : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_album(audio, &c_value); + media_content_debug("album : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_artist(audio, &c_value); + media_content_debug("artist : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_genre(audio, &c_value); + media_content_debug("genre : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_composer(audio, &c_value); + media_content_debug("composer : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_year(audio, &c_value); + media_content_debug("year : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_recorded_date(audio, &c_value); + media_content_debug("recorded_date : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_copyright(audio, &c_value); + media_content_debug("copyright : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_track_num(audio, &c_value); + media_content_debug("track_num : [%s] \n", c_value); + SAFE_FREE(c_value); + + audio_meta_get_bit_rate(audio, &i_value); + media_content_debug("bitrate : [%d] \n", i_value); + + audio_meta_get_sample_rate(audio, &i_value); + media_content_debug("samplerate : [%d] \n", i_value); + + audio_meta_get_channel(audio, &i_value); + media_content_debug("channel : [%d] \n", i_value); + + audio_meta_get_duration(audio, &i_value); + media_content_debug("duration : [%d] \n", i_value); + + audio_meta_get_played_count(audio, &i_value); + media_content_debug("played_count : [%d] \n", i_value); + + audio_meta_get_played_time(audio, &t_value); + media_content_debug("played_time : [%d] \n", t_value); + + audio_meta_get_played_position(audio, &i_value); + media_content_debug("played_position : [%d] \n", i_value); + + return true; +} + +bool get_video_meta(video_meta_h video) +{ + char *c_value = NULL; + int i_value = 0; + time_t t_value = 0; + + media_content_debug("=== video meta === \n"); + + video_meta_get_media_id(video, &c_value); + media_content_debug("video_id : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_title(video, &c_value); + media_content_debug("title : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_album(video, &c_value); + media_content_debug("album : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_artist(video, &c_value); + media_content_debug("artist : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_genre(video, &c_value); + media_content_debug("genre : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_composer(video, &c_value); + media_content_debug("omposer : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_year(video, &c_value); + media_content_debug("year : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_recorded_date(video, &c_value); + media_content_debug("recorded_date : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_copyright(video, &c_value); + media_content_debug("copyright : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_track_num(video, &c_value); + media_content_debug("track_num : [%s] \n", c_value); + SAFE_FREE(c_value); + + video_meta_get_bit_rate(video, &i_value); + media_content_debug("bitrate : [%d] \n", i_value); + + video_meta_get_duration(video, &i_value); + media_content_debug("duration : [%d] \n", i_value); + + video_meta_get_width(video, &i_value); + media_content_debug("width : [%d] \n", i_value); + + video_meta_get_height(video, &i_value); + media_content_debug("height : [%d] \n", i_value); + + video_meta_get_played_count(video, &i_value); + media_content_debug("played_count : [%d] \n", i_value); + + video_meta_get_played_time(video, &t_value); + media_content_debug("played_time : [%d] \n", t_value); + + video_meta_get_played_position(video, &i_value); + media_content_debug("played_position : [%d] \n", i_value); + + return true; +} + +bool gallery_folder_list_cb(media_folder_h folder, void *user_data) +{ + media_folder_h new_folder = NULL; + media_folder_clone(&new_folder, folder); + + GList **list = (GList**)user_data; + *list = g_list_append(*list, new_folder); + + return true; +} + +bool gallery_media_item_cb(media_info_h media, void *user_data) +{ + media_info_h new_media = NULL; + media_info_clone(&new_media, media); + + GList **list = (GList**)user_data; + *list = g_list_append(*list, new_media); + + return true; +} + +bool gallery_tag_item_cb(media_tag_h tag, void *user_data) +{ + media_tag_h new_tag = NULL; + media_tag_clone(&new_tag, tag); + + GList **list = (GList**)user_data; + *list = g_list_append(*list, new_tag); + + return true; +} + +bool gallery_bookmarks_cb(media_bookmark_h bookmark, void *user_data) +{ + media_bookmark_h new_bm = NULL; + media_bookmark_clone(&new_bm, bookmark); + + GList **list = (GList**)user_data; + *list = g_list_append(*list, new_bm); + + return true; +} + +bool media_item_cb(media_info_h media, void *user_data) +{ + char *c_value = NULL; + char *media_id = NULL; + int i_value = 0; + time_t t_value = 0; + bool b_value = false; + media_content_type_e media_type = 0; + unsigned long long size = 0; + + if(media == NULL) + { + media_content_debug("NO Item \n"); + return true; + } + + media_info_get_media_type(media, &media_type); + media_content_debug("media_type : [%d] \n", media_type); + + media_info_get_media_id(media, &media_id); + media_content_debug("media_id : [%s] \n", media_id); + +#if 1 + if(media_type == MEDIA_CONTENT_TYPE_MUSIC) + { + audio_meta_h audio; + + if(media_info_get_audio(media, &audio) == MEDIA_CONTENT_ERROR_NONE) + { + get_audio_meta(audio); + audio_meta_destroy(audio); + } + else + media_content_error("[audio_error] \n"); + + } + else if(media_type == MEDIA_CONTENT_TYPE_IMAGE) + { + image_meta_h image; + media_content_orientation_e orientation = 0; + + if(media_info_get_image(media, &image) == MEDIA_CONTENT_ERROR_NONE) + { + image_meta_get_orientation(image, &orientation); + media_content_debug("[image] orientation : %d\n", orientation); + image_meta_destroy(image); + } + else + media_content_error("[image_error] \n"); + + } + else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) + { + video_meta_h video; + + if(media_info_get_video(media, &video) == MEDIA_CONTENT_ERROR_NONE) + { + get_video_meta(video); + video_meta_destroy(video); + } + else + media_content_error("[video_error] \n"); + + } + else + { + media_content_debug("Other Content"); + } + + media_content_debug("=== media_info === \n"); + media_info_get_file_path(media, &c_value); + media_content_debug("file_path : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_display_name(media, &c_value); + media_content_debug("display_name : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_mime_type(media, &c_value); + media_content_debug("mime_type : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_thumbnail_path(media, &c_value); + media_content_debug("thumbnail_path : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_description(media, &c_value); + media_content_debug("description : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_author(media, &c_value); + media_content_debug("author : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_provider(media, &c_value); + media_content_debug("provider : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_content_name(media, &c_value); + media_content_debug("content_name : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_category(media, &c_value); + media_content_debug("category : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_location_tag(media, &c_value); + media_content_debug("location_tag : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_age_rating(media, &c_value); + media_content_debug("age_rating : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_keyword(media, &c_value); + media_content_debug("keyword : [%s] \n", c_value); + SAFE_FREE(c_value); + + media_info_get_size(media, &size); + media_content_debug("size : [%lld] \n", size); + + media_info_get_added_time(media, &t_value); + media_content_debug("added_time : [%d] \n", t_value); + + media_info_get_modified_time(media, &t_value); + media_content_debug("modified_time : [%d] \n", t_value); + + media_info_get_rating(media, &i_value); + media_content_debug("rating : [%d] \n", i_value); + + media_info_get_favorite(media, &b_value); + media_content_debug("favorite : [%d] \n", b_value); + + media_info_is_drm(media, &b_value); + media_content_debug("is_drm : [%d] \n", b_value); + + media_info_set_location_tag(media, "Test location tag"); + media_info_update_to_db(media); + SAFE_FREE(media_id); +#endif + return true; +} + +bool folder_list_cb(media_folder_h folder, void *user_data) +{ + int item_count; + char *folder_id = NULL; + char *folder_path = NULL; + char *folder_name = NULL; + media_content_storage_e storage_type; + bool ret; + media_folder_h *_folder = (media_folder_h*)user_data; + + if(folder != NULL) + { + media_folder_clone(_folder, folder); + + if(media_folder_get_folder_id(folder, &folder_id) != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_get_folder_id is failed\n"); + return false; + } + media_content_debug("folder_id = [%s] \n", folder_id); + + if(media_folder_get_path(folder, &folder_path) != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_get_path is failed\n"); + return false; + } + media_content_debug("folder_path = [%s] \n", folder_path); + SAFE_FREE(folder_path); + + if(media_folder_get_name(folder, &folder_name) != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_get_name is failed\n"); + return false; + } + media_content_debug("folder_name = [%s] \n", folder_name); + SAFE_FREE(folder_name); + + if(media_folder_get_storage_type(folder, &storage_type) != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_get_storage_type is failed\n"); + return false; + } + media_content_debug("storage_type = [%d] \n", storage_type); + + if(media_folder_get_media_count_from_db(folder_id, g_filter, &item_count) != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_get_media_count_from_db is failed\n"); + return false; + } + + media_folder_foreach_media_from_db(folder_id, g_filter, media_item_cb, NULL); + + SAFE_FREE(folder_id); + ret = true; + } + else + { + ret = false; + } + + return ret; +} + +bool test_album_from_db(int album_id) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_album_h album_h; + int test_album_id = 0; + char *album_name = NULL; + char *artist = NULL; + + ret = media_album_get_album_from_db(album_id, &album_h); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("error when get album \n"); + return false; + } + + if(media_album_get_album_id(album_h, &test_album_id) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("test_album_id : [%d] \n", test_album_id); + + if(media_album_get_name(album_h, &album_name) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("album_name : [%s] \n", album_name); + + if(media_album_get_artist(album_h, &artist) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("artist : [%s] \n", artist); + + SAFE_FREE(album_name); + SAFE_FREE(artist); + + media_album_destroy(album_h); + + return true; +} + +bool playlist_list_cb(media_playlist_h playlist, void *user_data) +{ + int playlist_id = 0; + char *playlist_name = NULL; + media_playlist_h playlist_h; + + media_content_debug("playlist_list_cb ====== \n"); + + GList **list = (GList**)user_data; + + if(playlist == NULL) + { + media_content_debug(" playlist handle is NULL \n"); + return false; + } + + media_playlist_get_playlist_id(playlist, &playlist_id); + media_content_debug("playlist_id : %d \n", playlist_id); + + if(user_data != NULL) + *list = g_list_append(*list, (gpointer)playlist_id); + + media_playlist_get_name(playlist, &playlist_name); + media_content_debug("playlist_name : %s \n", playlist_name); + SAFE_FREE(playlist_name); + + media_playlist_get_playlist_from_db(playlist_id, NULL, &playlist_h); + + media_playlist_destroy(playlist_h); + + return true; +} + +bool tag_list_cb(media_tag_h tag, void *user_data) +{ + int tag_id = 0; + char *tag_name = NULL; + + if(tag == NULL) + { + media_content_debug(" tag handle is NULL \n"); + return false; + } + + media_tag_get_tag_id(tag, &tag_id); + media_content_debug("tag_id : %d \n", tag_id); + + media_tag_get_name(tag, &tag_name); + media_content_debug("tag_name : %s \n", tag_name); + SAFE_FREE(tag_name); + + return true; +} + +bool bookmarks_cb(media_bookmark_h bookmark, void *user_data) +{ + media_bookmark_h *_bookmark = (media_bookmark_h*)bookmark; + + if(_bookmark != NULL) + { + char *name = NULL; + time_t time = 0; + int bookmark_id = 0; + + media_bookmark_get_bookmark_id(bookmark, &bookmark_id); + media_content_debug("bookmark_id : %d \n", bookmark_id); + + media_bookmark_get_thumbnail_path(bookmark, &name); + media_content_debug("bookmark thumbnail_path : %s \n", name); + SAFE_FREE(name); + + media_bookmark_get_marked_time(bookmark, &time); + media_content_debug("bookmark marked_time : %d \n", time); + } + + return true; +} + +bool album_list_cb(media_album_h album, void *user_data) +{ + int album_id = 0; + char *album_name = NULL; + char *artist = NULL; + char *album_art = NULL; + int media_count = 0; + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter; + + /*Set Filter*/ + char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/ + + ret = media_filter_create(&filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to create filter \n"); + return ret; + } + ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set condition \n"); + return ret; + } + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_NOCASE); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set order \n"); + return ret; + } + + if(album != NULL) + { + if(media_album_get_album_id(album, &album_id) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("album_id : [%d] \n", album_id); + + if(media_album_get_name(album, &album_name) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("album_name : [%s] \n", album_name); + + if(media_album_get_artist(album, &artist) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("artist : [%s] \n", artist); + + if(media_album_get_album_art(album, &album_art) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("album_art : [%s] \n", album_art); + + SAFE_FREE(album_name); + SAFE_FREE(artist); + SAFE_FREE(album_art); + + if(media_album_get_media_count_from_db(album_id, filter, &media_count) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("media_count : [%d] \n", media_count); + + if(media_album_foreach_media_from_db(album_id, filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) + return false; + + test_album_from_db(album_id); + } + else + { + media_content_error("album item not Found!!\n"); + return true; + } + + return true; +} + +bool group_list_cb(const char *group_name, void *user_data) +{ + int media_count = 0; + int *idx = user_data; + + media_content_debug("group item : [%s] [%d]\n", group_name, *idx); + + if(media_group_get_media_count_from_db(group_name, *idx, g_filter, &media_count) != MEDIA_CONTENT_ERROR_NONE) + return false; + + media_content_debug("media_count : [%d] \n", media_count); + + if(media_group_foreach_media_from_db(group_name, *idx, g_filter, media_item_cb, NULL) != MEDIA_CONTENT_ERROR_NONE) + return false; + + return true; +} + +bool playlist_item_cb(int playlist_member_id, media_info_h media, void *user_data) +{ + media_content_debug("playlist_member_id : [%d] \n", playlist_member_id); + + GList **list = (GList**)user_data; + *list = g_list_append(*list, (gpointer)playlist_member_id); + + //media_item_cb(media, user_data); + + return true; +} + +int test_filter_create(void) +{ + media_content_debug("\n============Filter Create============\n\n"); + + int ret = MEDIA_CONTENT_ERROR_NONE; + + /* Filter for media */ + char *condition = "MEDIA_TYPE=3"; /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/ + + ret = media_filter_create(&g_filter); + + /* Set condition and collate + * Condition string : You can make where statement of sql. + * Colation : You can use collation when comparing. + * Ex) In case of FILE_NAME='Samsung' as condition string, + * if you want to compare with NOCASE collation, + * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_NOCASE); + * if you want to compare in case-sensitive, + * call media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + */ + ret = media_filter_set_condition(g_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + + /* Collation of ordering + * If you want to get list, which is sorted by NOCASE, + * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_NOCASE); + * Or, + * call media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT); + */ + ret = media_filter_set_order(g_filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ARTIST, MEDIA_CONTENT_COLLATE_DEFAULT); + + /* Filter for group */ + char *g_condition = "TAG_NAME like \"\%my\%\""; + //char *g_condition = "BOOKMARK_MARKED_TIME > 300"; + + ret = media_filter_create(&g_filter_g); + + ret = media_filter_set_condition(g_filter_g, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT); + ret = media_filter_set_order(g_filter_g, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT); + + return ret; +} + +int test_filter_destroy(void) +{ + media_content_debug("\n============Filter Create============\n\n"); + + int ret = MEDIA_CONTENT_ERROR_NONE; + + ret = media_filter_destroy(g_filter); + + return ret; +} + +int test_connect_database(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug("\n============DB Connection Test============\n\n"); + + ret = media_content_connect(); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + { + media_content_debug("connection is success\n\n"); + } + else + media_content_error("connection is failed\n\n"); + + return ret; +} + +int test_gallery_scenario(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int i; + filter_h filter = NULL; + + int count; + GList *folder_list = NULL; + media_folder_h folder_handle = NULL; + + /* First, Get folder list */ + ret = media_folder_foreach_folder_from_db(filter, gallery_folder_list_cb, &folder_list); + if(ret < 0) { + media_content_error("media_folder_foreach_folder_from_db failed: %d", ret); + return -1; + } else { + media_content_debug("media_folder_foreach_folder_from_db success!!"); + char *folder_id; + char *folder_name; + char *folder_path; + + for(i = 0; i < g_list_length(folder_list); i++) { + folder_handle = (media_folder_h)g_list_nth_data(folder_list, i); + + media_folder_get_folder_id(folder_handle, &folder_id); + media_folder_get_name(folder_handle, &folder_name); + media_folder_get_path(folder_handle, &folder_path); + + media_content_debug("folder_id [%d] : %s\n", i, folder_id); + media_content_debug("folder_name [%d] : %s\n", i, folder_name); + media_content_debug("folder_path [%d] : %s\n", i, folder_path); + + + ret = media_folder_get_media_count_from_db(folder_id, filter, &count); + /* User should free these string */ + SAFE_FREE(folder_id); + SAFE_FREE(folder_name); + SAFE_FREE(folder_path); + if(ret < 0) { + media_content_error("media_folder_get_media_count_from_db failed: %d", ret); + return -1; + } else { + media_content_debug("media count [%d] : %d\n", i, count); + } + } + } + + /* To check performance */ + struct timeval start, end; + gettimeofday(&start, NULL); + + /* Second, Get all item list */ + media_info_h media_handle = NULL; + GList *all_item_list = NULL; + + media_content_collation_e collate_type = MEDIA_CONTENT_COLLATE_NOCASE; + media_content_order_e order_type = MEDIA_CONTENT_ORDER_DESC; + media_filter_create(&filter); + //media_filter_set_condition(filter, "MEDIA_TYPE = 0", collate_type); + media_filter_set_order(filter, order_type, MEDIA_DISPLAY_NAME, collate_type); + //media_filter_set_collate(filter, collate_type); + + ret = media_info_foreach_media_from_db(filter, gallery_media_item_cb, &all_item_list); + if(ret < 0) { + media_content_error("media_info_foreach_media_from_db failed: %d", ret); + return -1; + } else { + media_content_debug("media_info_foreach_media_from_db success"); + media_content_type_e media_type; + char *media_id = NULL; + char *media_name = NULL; + char *media_path = NULL; + + for(i = 0; i < g_list_length(all_item_list); i++) { + media_handle = (media_info_h)g_list_nth_data(all_item_list, i); + + media_info_get_media_id(media_handle, &media_id); + media_info_get_media_type(media_handle, &media_type); + media_info_get_display_name(media_handle, &media_name); + media_info_get_file_path(media_handle, &media_path); + + if(media_type == MEDIA_CONTENT_TYPE_IMAGE) { + image_meta_h image_handle; + int width, height; + media_content_orientation_e orientation; + char *datetaken; + + ret = media_info_get_image(media_handle, &image_handle); + if(ret < 0) { + media_content_error("media_info_get_image failed: %d", ret); + } else { + image_meta_get_width(image_handle, &width); + image_meta_get_height(image_handle, &height); + image_meta_get_orientation(image_handle, &orientation); + image_meta_get_date_taken(image_handle, &datetaken); + + media_content_debug("This is Image\n"); + media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s\n", width, height, orientation, datetaken); + } + + SAFE_FREE(datetaken); + image_meta_destroy(image_handle); + + } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) { + video_meta_h video_handle; + char *title, *artist, *album; + int duration; + time_t time_played; + + ret = media_info_get_video(media_handle, &video_handle); + if(ret < 0) { + media_content_error("media_info_get_video failed: %d", ret); + } else { + video_meta_get_title(video_handle, &title); + video_meta_get_artist(video_handle, &artist); + video_meta_get_album(video_handle, &album); + video_meta_get_duration(video_handle, &duration); + video_meta_get_played_time(video_handle, &time_played); + + media_content_debug("This is Video\n"); + media_content_debug("Title: %s, Album: %s, Artist: %s\nDuration: %d, Played time: %d\n", title, artist, album, duration, time_played); + } + + SAFE_FREE(title); + SAFE_FREE(artist); + SAFE_FREE(album); + + video_meta_destroy(video_handle); + } + //media_content_debug("media_id [%d] : %s\n", i, media_id); + //media_content_debug("media_name [%d] : %s\n", i, media_name); + //media_content_debug("media_path [%d] : %s\n", i, media_path); + + SAFE_FREE(media_id); + SAFE_FREE(media_name); + SAFE_FREE(media_path); + } + } + + media_filter_destroy(filter); + filter = NULL; + + /* To check performance */ + gettimeofday(&end, NULL); + long time = (end.tv_sec * 1000000 + end.tv_usec) - (start.tv_sec * 1000000 + start.tv_usec); + printf("Time : %ld\n", time); + + /* Third, Get item list of a folder */ + GList *item_list = NULL; + + for(i = 0; i < g_list_length(folder_list); i++) { + int j; + char *folder_name; + char *folder_id; + folder_handle = (media_folder_h)g_list_nth_data(folder_list, i); + + media_folder_get_folder_id(folder_handle, &folder_id); + media_folder_get_name(folder_handle, &folder_name); + + ret = media_folder_foreach_media_from_db(folder_id, filter, gallery_media_item_cb, &item_list); + SAFE_FREE(folder_id); + SAFE_FREE(folder_name); + + if(ret < 0) { + media_content_error("media_folder_foreach_media_from_db failed: %d", ret); + return -1; + } else { + media_content_error("media_folder_foreach_media_from_db success!", ret); + char *media_id = NULL; + char *media_name = NULL; + char *media_path = NULL; + media_content_type_e media_type = 0; + + for(j = 0; j < g_list_length(item_list); j++) { + media_handle = (media_info_h)g_list_nth_data(item_list, j); + + media_info_get_media_id(media_handle, &media_id); + media_info_get_display_name(media_handle, &media_name); + media_info_get_file_path(media_handle, &media_path); + media_info_get_media_type(media_handle, &media_type); + + media_content_debug("[%s] media_id [%d] : %s\n", folder_name, j, media_id); + media_content_debug("[%s] media_type [%d] : %d\n", folder_name, j, media_type); + media_content_debug("[%s] media_name [%d] : %s\n", folder_name, j, media_name); + media_content_debug("[%s] media_path [%d] : %s\n", folder_name, j, media_path); + + if(media_type == MEDIA_CONTENT_TYPE_IMAGE) { + image_meta_h image_handle; + int width, height; + media_content_orientation_e orientation; + char *datetaken; + + ret = media_info_get_image(media_handle, &image_handle); + if(ret < 0) { + media_content_error("media_info_get_image failed: %d", ret); + } else { + image_meta_get_width(image_handle, &width); + image_meta_get_height(image_handle, &height); + image_meta_get_orientation(image_handle, &orientation); + image_meta_get_date_taken(image_handle, &datetaken); + + media_content_debug("This is Image\n"); + media_content_debug("Width : %d, Height : %d, Orientation : %d, Date taken : %s\n", width, height, orientation, datetaken); + } + + SAFE_FREE(datetaken); + image_meta_destroy(image_handle); + + } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) { + video_meta_h video_handle; + char *title, *artist, *album; + int duration; + time_t time_played; + + ret = media_info_get_video(media_handle, &video_handle); + if(ret < 0) { + media_content_error("media_info_get_video failed: %d", ret); + } else { + video_meta_get_title(video_handle, &title); + video_meta_get_artist(video_handle, &artist); + video_meta_get_album(video_handle, &album); + video_meta_get_duration(video_handle, &duration); + video_meta_get_played_time(video_handle, &time_played); + + media_content_debug("This is Video\n"); + media_content_debug("Title: %s, Album: %s, Artist: %s\nDuration: %d, Played time: %d\n", title, artist, album, duration, time_played); + } + + SAFE_FREE(title); + SAFE_FREE(artist); + SAFE_FREE(album); + + video_meta_destroy(video_handle); + + /* Get bookmar list in case of video */ + media_bookmark_h bm_handle; + GList *bm_list = NULL; + + ret = media_info_foreach_bookmark_from_db(media_id, filter, gallery_bookmarks_cb, &bm_list); + if(ret < 0) { + media_content_error("media_info_foreach_bookmark_from_db failed: %d", ret); + } else { + media_content_error("media_info_foreach_bookmark_from_db success"); + int k; + + for(k = 0; k < g_list_length(bm_list); k++) { + bm_handle = (media_bookmark_h)g_list_nth_data(bm_list, k); + time_t marked_time; + char *thumb_path = NULL; + + media_bookmark_get_marked_time(bm_handle, &marked_time); + media_bookmark_get_thumbnail_path(bm_handle, &thumb_path); + + media_content_error("Bookmark time : %d\nBookmar thumb: %s\n", marked_time, thumb_path); + SAFE_FREE(thumb_path); + } + + /* Remove bookmark list */ + int l = 0; + if(bm_list) { + for(l = 0; l < g_list_length(bm_list); l++) { + bm_handle = (media_bookmark_h)g_list_nth_data(bm_list, l); + media_bookmark_destroy(bm_handle); + } + + g_list_free(bm_list); + } + + } + } + + SAFE_FREE(media_id); + SAFE_FREE(media_name); + SAFE_FREE(media_path); + } + } + } + + /* Get tag list */ + media_tag_h tag_handle = NULL; + GList *tag_list = NULL; + GList *media_list_in_tag = NULL; + + ret = media_tag_foreach_tag_from_db (filter, gallery_tag_item_cb, &tag_list); + + if(ret < 0) { + media_content_error("media_tag_foreach_tag_from_db failed: %d", ret); + return -1; + } else { + media_content_error("media_tag_foreach_tag_from_db success"); + char *tag_name; + int tag_id; + + for(i = 0; i < g_list_length(tag_list); i++) { + tag_handle = (media_tag_h)g_list_nth_data(tag_list, i); + media_tag_get_tag_id(tag_handle, &tag_id); + media_tag_get_name(tag_handle, &tag_name); + + printf("[%d] %s", tag_id, tag_name); + + ret = media_tag_foreach_media_from_db(tag_id, filter, gallery_media_item_cb, &media_list_in_tag); + if(ret < 0) { + media_content_error("media_tag_foreach_media_from_db failed: %d", ret); + return -1; + } else { + media_content_error("media_tag_foreach_media_from_db success"); + int j = 0; + media_info_h tag_media_handle; + char *media_id = NULL; + char *media_name = NULL; + char *media_path = NULL; + media_content_type_e media_type = 0; + + for(j = 0; j < g_list_length(media_list_in_tag); j++) { + tag_media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, j); + media_info_get_media_id(tag_media_handle, &media_id); + media_info_get_display_name(tag_media_handle, &media_name); + media_info_get_file_path(tag_media_handle, &media_path); + media_info_get_media_type(tag_media_handle, &media_type); + + media_content_debug("[%s] media_id [%d] : %s\n", tag_name, j, media_id); + media_content_debug("[%s] media_type [%d] : %d\n", tag_name, j, media_type); + media_content_debug("[%s] media_name [%d] : %s\n", tag_name, j, media_name); + media_content_debug("[%s] media_path [%d] : %s\n", tag_name, j, media_path); + } + SAFE_FREE(media_id); + SAFE_FREE(media_name); + SAFE_FREE(media_path); + } + SAFE_FREE(tag_name); + } + } + + /* Remove folder list */ + if(folder_list) { + for(i = 0; i < g_list_length(folder_list); i++) { + folder_handle = (media_folder_h)g_list_nth_data(folder_list, i); + media_folder_destroy(folder_handle); + } + + g_list_free(folder_list); + } + + /* Remove all items list */ + if(all_item_list) { + for(i = 0; i < g_list_length(all_item_list); i++) { + media_handle = (media_info_h)g_list_nth_data(all_item_list, i); + media_info_destroy(media_handle); + } + + g_list_free(all_item_list); + } + + /* Remove items list */ + if(item_list) { + for(i = 0; i < g_list_length(item_list); i++) { + media_handle = (media_info_h)g_list_nth_data(item_list, i); + media_info_destroy(media_handle); + } + + g_list_free(item_list); + } + + /* Remove tag list */ + if(tag_list) { + for(i = 0; i < g_list_length(tag_list); i++) { + tag_handle = (media_tag_h)g_list_nth_data(tag_list, i); + media_tag_destroy(tag_handle); + } + + g_list_free(tag_list); + } + + /* Remove media list in a tag */ + if(media_list_in_tag) { + for(i = 0; i < g_list_length(media_list_in_tag); i++) { + media_handle = (media_info_h)g_list_nth_data(media_list_in_tag, i); + media_info_destroy(media_handle); + } + + g_list_free(media_list_in_tag); + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +/*Get All Music file. sort by Title and not case sensitive*/ +int test_get_all_music_files(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + filter_h filter; + + /*Set Filter*/ + char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/ + + ret = media_filter_create(&filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to create filter \n"); + return ret; + } + ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set condition \n"); + return ret; + } + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_TITLE, MEDIA_CONTENT_COLLATE_NOCASE); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set order \n"); + return ret; + } + + /*Get Media Count*/ + ret = media_info_get_media_count_from_db(filter, &media_count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_filter_destroy(filter); + media_content_error("Fail to get media count \n"); + return ret; + } + + media_content_debug("media_count : [%d],\n", media_count); + + ret = media_info_foreach_media_from_db(filter, media_item_cb, NULL); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_filter_destroy(filter); + media_content_error("Fail to get media \n"); + return ret; + } + + return ret; +} + +int test_media_info_operation(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int media_count = 0; + + media_content_debug("\n============Media info Test============\n\n"); + + test_filter_create(); + + media_info_get_media_count_from_db(g_filter, &media_count); + media_content_debug("media_count : [%d],\n", media_count); + + ret = media_info_foreach_media_from_db(g_filter, media_item_cb, NULL); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("media_info_foreach_media_from_db is success\n\n"); + else + media_content_error("media_info_foreach_media_from_db is failed\n\n"); + + test_filter_destroy(); + + return ret; +} + +int test_media_info_operation_2(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int bookmark_count = 0; + + media_content_debug("\n============Media info Test 2============\n\n"); + + test_filter_create(); + +#if 0 + /* Bookmark */ + char *thumbnail_path1 = "/opt/media/Images and videos/My video clips/teat11.jpg"; + media_bookmark_insert_to_db(test_video_id, 100, thumbnail_path1); + media_bookmark_insert_to_db(test_video_id, 200, thumbnail_path1); + + media_info_get_bookmark_count_from_db(test_video_id, g_filter_g, &bookmark_count); + + media_content_debug("bookmark_count : [%d],\n", bookmark_count); + + ret = media_info_foreach_bookmark_from_db(test_video_id, g_filter_g, bookmarks_cb, NULL); +#endif + + /* Tag */ + media_info_get_tag_count_from_db(test_audio_id, g_filter_g, &bookmark_count); + + media_content_debug("tag_count : [%d],\n", bookmark_count); + + ret = media_info_foreach_tag_from_db(test_audio_id, g_filter_g, tag_list_cb, NULL); + + test_filter_destroy(); + + return ret; +} + +int test_folder_operation(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + filter_h filter; + media_folder_h folder = NULL; + char *folder_id = NULL; + int folder_count = 0; + + media_content_debug("\n============Folder Test============\n\n"); + + test_filter_create(); + + ret = media_filter_create(&filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_filter_create is failed\n"); + return ret; + } + + media_filter_set_condition(filter, "(MEDIA_TYPE = 0 or MEDIA_TYPE = 1) and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/ + media_filter_set_offset(filter, 0,5); + media_filter_set_order(filter,MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE); + + ret = media_folder_get_folder_count_from_db(filter, &folder_count); + media_content_debug("Folder count : %d", folder_count); + + ret = media_folder_foreach_folder_from_db(filter, folder_list_cb, &folder); + + //test.3 get the media list in first folder + filter_h m_filter = NULL; + ret = media_filter_create(&m_filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_info_filter_create is failed\n"); + return ret; + } + + media_filter_set_condition(m_filter, "MEDIA_TYPE=1 and MEDIA_STORAGE_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/ + media_filter_set_offset(m_filter, 0,5); + media_filter_set_order(m_filter,MEDIA_CONTENT_ORDER_DESC, MEDIA_PATH, MEDIA_CONTENT_COLLATE_NOCASE); + + media_folder_get_folder_id(folder, &folder_id); + media_content_debug("folder_id : %s", folder_id); + + ret = media_folder_foreach_media_from_db(folder_id, m_filter, media_item_cb, NULL); + + if(ret != MEDIA_CONTENT_ERROR_NONE) + { + media_content_error("[ERROR] media_folder_foreach_media_from_db is failed, error code : %d\n", ret); + } + + media_filter_destroy(filter); + media_filter_destroy(m_filter); + + test_filter_create(); + + return ret; +} + +int test_playlist_operation(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_playlist_h playlist_1 = NULL; + media_playlist_h playlist_2 = NULL; + media_playlist_h playlist_3 = NULL; + int playlist_id_1 = 0; + int playlist_id_2 = 0; + int playlist_id_3 = 0; + char *playlist_name_1 = "myPlaylist_1"; + char *playlist_name_2 = "myPlaylist_2"; + char *playlist_name_3 = "myPlaylist_3"; + int playlist_count = 0; + int media_count = 0; + int order_1 = 0; + int order_2 = 0; + int order_3 = 0; + int order_4 = 0; + int order_5 = 0; + filter_h filter = NULL; + filter_h m_filter = NULL; + + media_content_debug("\n============Playlist Test============\n\n"); + + /* Filter for playlist */ + + char *condition = "(MEDIA_TYPE=1 or MEDIA_TYPE=3)"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/ +#if 0 + ret = media_filter_create(&filter); + + ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_NOCASE); + + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_NAME, MEDIA_CONTENT_COLLATE_NOCASE); +#endif + + /* Create Playlist */ + media_playlist_insert_to_db(playlist_name_1, &playlist_1); + media_playlist_insert_to_db(playlist_name_2, &playlist_2); + media_playlist_insert_to_db(playlist_name_3, &playlist_3); + + if(playlist_1 != NULL) + { + /* Add media to Playlist */ + media_playlist_add_media(playlist_1, test_audio_id); + media_playlist_add_media(playlist_1, test_audio_id); + media_playlist_add_media(playlist_1, test_video_id); + media_playlist_update_to_db(playlist_1); + } + + if(playlist_2 != NULL) + { + media_playlist_add_media(playlist_2, test_audio_id); + media_playlist_add_media(playlist_2, test_audio_id); + media_playlist_update_to_db(playlist_2); + } + + /* Get Playlist Count*/ + media_playlist_get_playlist_count_from_db(filter, &playlist_count); + media_content_debug("playlist_count [%d] \n", playlist_count); + + /* Get Playlist*/ + GList *playlist_id_list = NULL; + media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, &playlist_id_list); + + /* Get Playlist id*/ + playlist_id_1 = (int)g_list_nth_data(playlist_id_list, 0); + playlist_id_2 = (int)g_list_nth_data(playlist_id_list, 1); + playlist_id_3 = (int)g_list_nth_data(playlist_id_list, 2); + media_content_debug("playlist_id_1 [%d] \n", playlist_id_1); + media_content_debug("playlist_id_2 [%d] \n", playlist_id_2); + media_content_debug("playlist_id_3 [%d] \n", playlist_id_3); + + /* Filter for media*/ + ret = media_filter_create(&m_filter); + + ret = media_filter_set_condition(m_filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_filter_set_order(m_filter, MEDIA_CONTENT_ORDER_ASC, PLAYLIST_MEMBER_ORDER, MEDIA_CONTENT_COLLATE_DEFAULT); + + /* Get media count */ + media_playlist_get_media_count_from_db(playlist_id_1, m_filter, &media_count); + media_content_debug("playlist_1_media_count [%d] \n", media_count); + + media_playlist_get_media_count_from_db(playlist_id_2, m_filter, &media_count); + media_content_debug("playlist_2_media_count [%d] \n", media_count); + + media_playlist_get_media_count_from_db(playlist_id_3, m_filter, &media_count); + media_content_debug("playlist_3_media_count [%d] \n", media_count); + + /* Get media of playlist */ + GList *playlist_member_id_list = NULL; + GList *playlist_member_id_list_1 = NULL; + + media_playlist_foreach_media_from_db(playlist_id_1, m_filter, playlist_item_cb, &playlist_member_id_list); + media_playlist_foreach_media_from_db(playlist_id_2, m_filter, playlist_item_cb, &playlist_member_id_list_1); + + int playlist_member_id_1_1 =0; + int playlist_member_id_1_2 =0; + int playlist_member_id_1_3 =0; + int playlist_member_id_2_1 =0; + int playlist_member_id_2_2 =0; + + playlist_member_id_1_1 = (int)g_list_nth_data(playlist_member_id_list, 0); + playlist_member_id_1_2 = (int)g_list_nth_data(playlist_member_id_list, 1); + playlist_member_id_1_3 = (int)g_list_nth_data(playlist_member_id_list, 2); + playlist_member_id_2_1 = (int)g_list_nth_data(playlist_member_id_list_1, 0); + playlist_member_id_2_2 = (int)g_list_nth_data(playlist_member_id_list_1, 1); + + media_content_debug("playlist_member_id_1_1 [%d] \n", playlist_member_id_1_1); + media_content_debug("playlist_member_id_1_2 [%d] \n", playlist_member_id_1_2); + media_content_debug("playlist_member_id_1_3 [%d] \n", playlist_member_id_1_3); + media_content_debug("playlist_member_id_2_1 [%d] \n", playlist_member_id_2_1); + media_content_debug("playlist_member_id_2_2 [%d] \n", playlist_member_id_2_2); + + media_playlist_get_play_order(playlist_1, playlist_member_id_1_1, &order_1); + media_playlist_get_play_order(playlist_1, playlist_member_id_1_2, &order_2); + media_playlist_get_play_order(playlist_1, playlist_member_id_1_3, &order_3); + media_playlist_get_play_order(playlist_2, playlist_member_id_2_1, &order_4); + media_playlist_get_play_order(playlist_2, playlist_member_id_2_2, &order_5); + media_content_debug("order_1 [%d] order_2 [%d] order_3 [%d] order_4 [%d] order_5 [%d]\n", order_1, order_2, order_3, order_4, order_5); + + /* Update Playlist */ + media_playlist_remove_media(playlist_2, playlist_member_id_2_1); + media_playlist_add_media(playlist_2, test_video_id); + media_playlist_set_name(playlist_2, "test_playlist"); + media_playlist_set_play_order(playlist_2, playlist_member_id_2_2, order_5+100); + media_playlist_update_to_db(playlist_2); + + /* Get Updated Playlist*/ + media_playlist_foreach_playlist_from_db(filter, playlist_list_cb, NULL); + + /* deletes the playlist */ + //media_playlist_delete_from_db(playlist_id_1); + //media_playlist_delete_from_db(playlist_id_2); + + if(playlist_1 != NULL) + media_playlist_destroy(playlist_1); + if(playlist_2 != NULL) + media_playlist_destroy(playlist_2); + if(playlist_3 != NULL) + media_playlist_destroy(playlist_3); + + g_list_free(playlist_id_list); + g_list_free(playlist_member_id_list); + g_list_free(playlist_member_id_list_1); + + if(filter != NULL) + ret = media_filter_destroy(filter); + if(m_filter != NULL) + ret = media_filter_destroy(m_filter); + + return ret; +} + +int test_tag_operation(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_tag_h tag_1; + media_tag_h tag_2; + media_tag_h tag_3; + int tag_id_1 = 0; + int tag_id_2 = 0; + int tag_id_3 = 0; + char *tag_name_1 = "myTag_1"; + char *tag_name_2 = "myTag_2"; + char *tag_name_3 = "myTag_3"; + int tag_count = 0; + int media_count = 0; + filter_h filter; + + media_content_debug("\n============Tag Test============\n\n"); + + char *g_condition = "TAG_NAME like \"%%my%%\""; + + ret = media_filter_create(&filter); + + ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, TAG_NAME, MEDIA_CONTENT_COLLATE_DEFAULT); + + /* Create Tag */ + media_tag_insert_to_db(tag_name_1, &tag_1); + media_tag_insert_to_db(tag_name_2, &tag_2); + media_tag_insert_to_db(tag_name_3, &tag_3); + + /* Add media to Tag */ + media_tag_add_media(tag_1, test_audio_id); + media_tag_add_media(tag_1, test_video_id); + media_tag_update_to_db(tag_1); + + media_tag_add_media(tag_2, test_audio_id); + media_tag_update_to_db(tag_2); + + /* Get Tag Count*/ + media_tag_get_tag_count_from_db(filter, &tag_count); + media_content_debug("tag_count [%d] \n", tag_count); + + /* Get Tag*/ + media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL); + + /* Get Tag id*/ + media_tag_get_tag_id(tag_1, &tag_id_1); + media_content_debug("tag_id_1 [%d] \n", tag_id_1); + + media_tag_get_tag_id(tag_2, &tag_id_2); + media_content_debug("tag_id_2 [%d] \n", tag_id_2); + + media_tag_get_tag_id(tag_3, &tag_id_3); + media_content_debug("tag_id_3 [%d] \n", tag_id_3); + + /* Get media count */ + media_tag_get_media_count_from_db(tag_id_1, NULL, &media_count); + media_content_debug("tag_1_media_count [%d] \n", media_count); + + media_tag_get_media_count_from_db(tag_id_2, NULL, &media_count); + media_content_debug("tag_2_media_count [%d] \n", media_count); + + /* Get media of Tag */ + media_tag_foreach_media_from_db(tag_id_1, NULL, media_item_cb, NULL); + media_tag_foreach_media_from_db(tag_id_2, NULL, media_item_cb, NULL); + + /* Update Tag */ + media_tag_add_media(tag_2, test_video_id); + media_tag_set_name(tag_2, "test_tag"); + media_tag_update_to_db(tag_2); + + /* Get Updated Tag*/ + media_tag_foreach_tag_from_db(filter, tag_list_cb, NULL); + + /* deletes the tag */ + media_tag_delete_from_db(tag_id_1); + media_tag_delete_from_db(tag_id_2); + + media_tag_destroy(tag_1); + media_tag_destroy(tag_2); + + ret = media_filter_destroy(filter); + + return ret; +} + + +int test_bookmark_operation(void) +{ + //bookmark is only supported for video information. + int ret = MEDIA_CONTENT_ERROR_NONE; + int bookmark_count = 0; + filter_h filter; + + media_content_debug("\n============Bookmark Test============\n\n"); + + char *g_condition = "BOOKMARK_MARKED_TIME > 300"; + + ret = media_filter_create(&filter); + + ret = media_filter_set_condition(filter, g_condition, MEDIA_CONTENT_COLLATE_DEFAULT); + + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_DESC, BOOKMARK_MARKED_TIME, MEDIA_CONTENT_COLLATE_DEFAULT); + + //insert bookmark to video + char *thumbnail_path1 = "/opt/media/Images and videos/My video clips/teat11.jpg"; + media_bookmark_insert_to_db(test_video_id, 400, thumbnail_path1); + media_bookmark_insert_to_db(test_video_id, 600, thumbnail_path1); + + media_bookmark_get_bookmark_count_from_db(filter, &bookmark_count); + media_content_debug("bookmark_count = [%d]\n", bookmark_count); + + media_filter_destroy(filter); + + return ret; +} + +int test_album_list(void) +{ + media_content_debug("\n============Album Test============\n\n"); + + int ret = MEDIA_CONTENT_ERROR_NONE; + int album_count = 0; + filter_h filter; + + /*Set Filter*/ + char *condition = "MEDIA_TYPE=3"; /*0-image, 1-video, 2-sound, 3-music, 4-other*/ + + ret = media_filter_create(&filter); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to create filter \n"); + return ret; + } + ret = media_filter_set_condition(filter, condition, MEDIA_CONTENT_COLLATE_DEFAULT); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set condition \n"); + return ret; + } + ret = media_filter_set_order(filter, MEDIA_CONTENT_ORDER_ASC, MEDIA_ALBUM, MEDIA_CONTENT_COLLATE_NOCASE); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("Fail to set order \n"); + return ret; + } + + ret = media_album_get_album_count_from_db(filter, &album_count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_filter_destroy(filter); + return ret; + } else { + media_content_debug("album_count [%d] \n", album_count); + } + + ret = media_album_foreach_album_from_db(filter, album_list_cb, NULL); + + ret = media_filter_destroy(filter); + + return ret; +} + +int test_group_operation(void) +{ + media_content_debug("\n============Group Test============\n\n"); + + int ret = MEDIA_CONTENT_ERROR_NONE; + int group_count = 0; + int idx = 0; + + ret = test_filter_create(); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + media_content_error("[%d]error(0x%08x)", __LINE__, ret); + return ret; + } + + for(idx = 0; idx <= MEDIA_CONTENT_GROUP_KEYWORD; idx++) + { + ret = media_group_get_group_count_from_db(g_filter, idx, &group_count); + if(ret != MEDIA_CONTENT_ERROR_NONE) { + test_filter_destroy(); + media_content_error("media_group_get_group_count_from_db fail. idx=[%d]", ret, idx); + return ret; + } else { + media_content_debug("[%2d]group_count [%d] \n", idx, group_count); + } + + ret = media_group_foreach_group_from_db(g_filter, idx, group_list_cb, &idx); + } + ret = test_filter_destroy(); + + return ret; +} + +int test_update_operation() +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + int i; + media_info_h media_handle = NULL; + GList *all_item_list = NULL; + + /* Get all item list */ + ret = media_info_foreach_media_from_db(NULL, gallery_media_item_cb, &all_item_list); + if(ret < 0) { + media_content_error("media_info_foreach_media_from_db failed: %d", ret); + return -1; + } else { + media_content_debug("media_info_foreach_media_from_db success"); + char *media_id = NULL; + char *media_path = NULL; + media_content_type_e media_type = 0; + + for(i = 0; i < g_list_length(all_item_list); i++) { + media_handle = (media_info_h)g_list_nth_data(all_item_list, i); + + media_info_get_media_id(media_handle, &media_id); + media_info_get_file_path(media_handle, &media_path); + media_info_get_media_type(media_handle, &media_type); + + media_content_debug("media_id [%d] : %s\n", i, media_id); + media_content_debug("media_type [%d] : %d\n", i, media_type); + media_content_debug("media_path [%d] : %s\n", i, media_path); +#if 0 + if(media_type == MEDIA_CONTENT_TYPE_IMAGE) { + image_meta_h image_handle; + media_content_orientation_e orientation; + + ret = media_info_get_image_from_db(media_id, &image_handle); + if(ret < 0) { + media_content_error("media_info_get_image_from_db failed: %d", ret); + } else { + media_content_debug("media_info_get_image_from_db success"); + + //update image meta + orientation = MEDIA_CONTENT_ORIENTATION_ROT_180; + image_meta_set_orientation(image_handle, orientation); + + ret = image_meta_update_to_db(image_handle); + if(ret < 0) { + media_content_error("image_meta_update_to_db failed: %d", ret); + } else { + media_content_debug("image_meta_update_to_db success"); + } + } + + } else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) { + video_meta_h video_handle; + + ret = media_info_get_video_from_db(media_id, &video_handle); + if(ret < 0) { + media_content_error("media_info_get_video_from_db failed: %d", ret); + } else { + media_content_debug("media_info_get_video_from_db success"); + + //update video meta + video_meta_set_played_count(video_handle,5); + video_meta_set_played_time(video_handle,5); + video_meta_set_played_position(video_handle,5); + video_meta_update_to_db(video_handle); + + ret = video_meta_update_to_db(video_handle); + if(ret < 0) { + media_content_error("video_meta_update_to_db failed: %d", ret); + } else { + media_content_debug("video_meta_update_to_db success"); + } + } + } else if(media_type == MEDIA_CONTENT_TYPE_MUSIC) {//update audio meta + audio_meta_h audio_handle = NULL; + ret = media_info_get_audio_from_db(media_id, &audio_handle); + if(ret < 0) { + media_content_error("media_info_get_audio_from_db failed: %d", ret); + } else { + media_content_debug("media_info_get_audio_from_db success"); + + audio_meta_set_played_count(audio_handle,5); + audio_meta_set_played_time(audio_handle,1000); + audio_meta_set_played_position(audio_handle,180); + + ret = audio_meta_update_to_db(audio_handle); + if(ret < 0) { + media_content_error("audio_meta_update_to_db failed: %d", ret); + } else { + media_content_debug("audio_meta_update_to_db success"); + } + } + + } +#endif + } + } + + return MEDIA_CONTENT_ERROR_NONE; +} + +int test_insert(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + //char *path = "/opt/media/Images/Default.jpg"; + char *path = "/opt/media/Others/other.txt"; + //char *path = NULL; + media_info_h media_item = NULL; + media_content_debug("\n============DB Insert Test============\n\n"); + + ret = media_info_insert_to_db(path, &media_item); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("Insertion is success\n\n"); + else + media_content_error("Insertion is failed\n\n"); + + char *media_id = NULL; + + media_info_get_media_id(media_item, &media_id); + + printf("Media ID: %s\n", media_id); + + ret = media_info_update_to_db(media_item); + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("media_info_update_to_db is success\n"); + else + media_content_error("media_info_update_to_db is failed\n"); + + return ret; +} + +int test_move(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + const char *move_media_id = "60aea677-4742-408e-b5f7-f2628062d06d"; + char *dst_path = "/opt/media/Images/XX/Default1.jpg"; + media_info_h move_media = NULL; + + ret = media_info_get_media_from_db(move_media_id, &move_media); + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("media_info_get_media_from_db success\n\n"); + else + media_content_error("media_info_get_media_from_db failed: %d\n\n", ret); + + media_content_debug("\n============DB Move Test============\n\n"); + + if(move_media) { + ret = media_info_move_media_to_db(move_media, dst_path); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("Move is success\n\n"); + else + media_content_error("Move is failed\n\n"); + } else { + media_content_debug("There is no item : %s\n", move_media_id); + } + + return ret; +} + +int test_disconnect_database(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + media_content_debug("\n============DB Disconnection Test============\n\n"); + + ret = media_content_disconnect(); + + if(ret == MEDIA_CONTENT_ERROR_NONE) + media_content_debug("disconnection is success\n\n"); + else + media_content_error("disconnection is failed\n\n"); + + return ret; +} + +int g_total_photo_size = 0; +int g_total_video_size = 0; +int g_total_mp3_size = 0; +int g_total_voice_memo_size = 0; + +bool dft_cb(media_info_h media, void *user_data) +{ + unsigned long long file_size = 0; + media_content_type_e media_type = -1; + char *mime_type = NULL; + + if(media == NULL) + { + return true; + } + + media_info_get_media_type(media, &media_type); + media_info_get_size(media, &file_size); + media_info_get_mime_type(media, &mime_type); + + if(media_type == MEDIA_CONTENT_TYPE_IMAGE) + { + g_total_photo_size += file_size; + } + else if(media_type == MEDIA_CONTENT_TYPE_VIDEO) + { + g_total_video_size += file_size; + } + else if(media_type == MEDIA_CONTENT_TYPE_SOUND) + { + g_total_voice_memo_size += file_size; + } + else if(media_type == MEDIA_CONTENT_TYPE_MUSIC) + { + if((mime_type != NULL) && (!strcmp("audio/mpeg", mime_type))) + { + g_total_mp3_size += file_size; + } + else + { + g_total_voice_memo_size += file_size; + } + } + else + { + printf("invalid media_type\n"); + } + + if(mime_type != NULL) + free(mime_type); + + return true; + +} + +int DFT_test(void) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + printf("\n============DFT_test============\n\n"); + + filter_h filter = NULL; + int media_cnt = 0; + + /*MEDIA_TYPE 0-image, 1-video, 2-sound, 3-music, 4-other*/ + + ret = media_filter_create(&filter); + +/*Internal Memory*/ + printf("[Internal Memory]\n"); + /*1. Photo ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Photo Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Photo count = [%d]\n", media_cnt); + + /*Get Photo Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Photo size = [%d]\n", g_total_photo_size); + + /*2. Video ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Video Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Video count = [%d]\n", media_cnt); + + /*Get Video Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Video size = [%d]\n", g_total_video_size); + + /*3. MP3 ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get MP3 Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("MP3 count = [%d]\n", media_cnt); + + /*Get MP3 Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("MP3 size = [%d]\n", g_total_mp3_size); + + /*4. Voice Memo ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=0 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Voice Memo Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Voice Memo count = [%d]\n", media_cnt); + + /*Get Voice Memo Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Voice Memo size = [%d]\n", g_total_voice_memo_size); + + g_total_photo_size = 0; + g_total_video_size = 0; + g_total_mp3_size = 0; + g_total_voice_memo_size = 0; + +/*External Memory*/ + printf("\n[External Memory]\n"); + /*1. Photo ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=0", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Photo Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Photo count = [%d]\n", media_cnt); + + /*Get Photo Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Photo size = [%d]\n", g_total_photo_size); + + /*2. Video ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=1", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Video Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Video count = [%d]\n", media_cnt); + + /*Get Video Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Video size = [%d]\n", g_total_video_size); + + /*3. MP3 ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND MEDIA_TYPE=3 AND MEDIA_MIME_TYPE=\"audio/mpeg\"", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get MP3 Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("MP3 count = [%d]\n", media_cnt); + + /*Get MP3 Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("MP3 size = [%d]\n", g_total_mp3_size); + + /*4. Voice Memo ============================================================*/ + ret = media_filter_set_condition(filter, "MEDIA_STORAGE_TYPE=1 AND (MEDIA_MIME_TYPE=\"audio/AMR\" OR MEDIA_MIME_TYPE=\"audio/mp4\")", MEDIA_CONTENT_COLLATE_DEFAULT); + + /*Get Voice Memo Count*/ + ret = media_info_get_media_count_from_db(filter, &media_cnt); + printf("Voice Memo count = [%d]\n", media_cnt); + + /*Get Voice Memo Size*/ + ret = media_info_foreach_media_from_db(filter, dft_cb, NULL); + printf("Voice Memo size = [%d]\n", g_total_voice_memo_size); + ret = media_filter_destroy(filter); + + return 0; +} + +int main(int argc, char *argv[]) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_content_debug("--- content manager test start ---\n\n"); + + ret = test_connect_database(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return MEDIA_CONTENT_ERROR_NONE; + +#if 0 + ret = test_move(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_gallery_scenario(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_get_all_music_files(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_media_info_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_folder_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_playlist_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_tag_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_bookmark_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_album_list(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_group_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_update_operation(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_insert(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = test_move(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + ret = DFT_test(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; +#endif + + ret = test_disconnect_database(); + if(ret != MEDIA_CONTENT_ERROR_NONE) + return ret; + + media_content_debug("--- content manager test end ---\n"); + + return ret; +} |