diff options
author | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:44 +0900 |
---|---|---|
committer | Kibum Kim <kb0929.kim@samsung.com> | 2012-01-07 00:42:44 +0900 |
commit | e6ef61572c48a551b22b95d50c4ed427087cbdc7 (patch) | |
tree | 881c34dac42aff22035de1ffbf5eba60dac1edcd | |
parent | 6fefcfb3259ce0088331bcb92224dfecd29fe898 (diff) | |
download | media-content-e6ef61572c48a551b22b95d50c4ed427087cbdc7.tar.gz media-content-e6ef61572c48a551b22b95d50c4ed427087cbdc7.tar.bz2 media-content-e6ef61572c48a551b22b95d50c4ed427087cbdc7.zip |
Git init
34 files changed, 12102 insertions, 0 deletions
@@ -0,0 +1,2 @@ +Dongyoung Kim <dydot1.kim@samsung.com> +Jongchul Park <jc0204.park@samsung.com> diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..afe6d8c --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,89 @@ +CMAKE_MINIMUM_REQUIRED(VERSION 2.6) +SET(fw_name "capi-content-media-content") + +PROJECT(${fw_name}) + +SET(CMAKE_INSTALL_PREFIX /usr) +SET(PREFIX ${CMAKE_INSTALL_PREFIX}) + +SET(INC_DIR include) +INCLUDE_DIRECTORIES(${INC_DIR}) + +SET(dependents "dlog libmedia-service drm-service aul capi-base-common") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_name} REQUIRED ${dependents}) +FOREACH(flag ${${fw_name}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") +SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") + +IF("${ARCH}" STREQUAL "arm") + ADD_DEFINITIONS("-DTARGET") +ENDIF("${ARCH}" STREQUAL "arm") + +ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") +ADD_DEFINITIONS("-DSLP_DEBUG") + +SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=/usr/lib") + +aux_source_directory(src SOURCES) +ADD_LIBRARY(${fw_name} SHARED ${SOURCES}) + +TARGET_LINK_LIBRARIES(${fw_name} ${${fw_name}_LDFLAGS}) + +INSTALL(TARGETS ${fw_name} DESTINATION lib) +INSTALL( + DIRECTORY ${INC_DIR}/ DESTINATION include/media-content + FILES_MATCHING + PATTERN "*_private.h" EXCLUDE + PATTERN "${INC_DIR}/*.h" + ) + +SET(PC_NAME ${fw_name}) +SET(PC_REQUIRED ${dependents}) +SET(PC_LDFLAGS -l${fw_name}) +SET(PC_CFLAGS -I\${includedir}/content) + +CONFIGURE_FILE( + capi-content-media-content.pc.in + ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc + @ONLY +) +INSTALL(FILES ${CMAKE_CURRENT_SOURCE_DIR}/${fw_name}.pc DESTINATION lib/pkgconfig) + +ADD_SUBDIRECTORY(test) + +IF(UNIX) + +ADD_CUSTOM_TARGET (distclean @echo cleaning for source distribution) +ADD_CUSTOM_COMMAND( + DEPENDS clean + COMMENT "distribution clean" + COMMAND find + ARGS . + -not -name config.cmake -and \( + -name tester.c -or + -name Testing -or + -name CMakeFiles -or + -name cmake.depends -or + -name cmake.check_depends -or + -name CMakeCache.txt -or + -name cmake.check_cache -or + -name *.cmake -or + -name Makefile -or + -name core -or + -name core.* -or + -name gmon.out -or + -name install_manifest.txt -or + -name *.pc -or + -name *~ \) + | grep -v TC | xargs rm -rf + TARGET distclean + VERBATIM +) + +ENDIF(UNIX) + @@ -0,0 +1,206 @@ +Copyright (c) 2000 - 2011 Samsung Electronics Co., Ltd. All rights reserved.
+
+ Apache License
+ Version 2.0, January 2004
+ http://www.apache.org/licenses/
+
+ TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
+
+ 1. Definitions.
+
+ "License" shall mean the terms and conditions for use, reproduction,
+ and distribution as defined by Sections 1 through 9 of this document.
+
+ "Licensor" shall mean the copyright owner or entity authorized by
+ the copyright owner that is granting the License.
+
+ "Legal Entity" shall mean the union of the acting entity and all
+ other entities that control, are controlled by, or are under common
+ control with that entity. For the purposes of this definition,
+ "control" means (i) the power, direct or indirect, to cause the
+ direction or management of such entity, whether by contract or
+ otherwise, or (ii) ownership of fifty percent (50%) or more of the
+ outstanding shares, or (iii) beneficial ownership of such entity.
+
+ "You" (or "Your") shall mean an individual or Legal Entity
+ exercising permissions granted by this License.
+
+ "Source" form shall mean the preferred form for making modifications,
+ including but not limited to software source code, documentation
+ source, and configuration files.
+
+ "Object" form shall mean any form resulting from mechanical
+ transformation or translation of a Source form, including but
+ not limited to compiled object code, generated documentation,
+ and conversions to other media types.
+
+ "Work" shall mean the work of authorship, whether in Source or
+ Object form, made available under the License, as indicated by a
+ copyright notice that is included in or attached to the work
+ (an example is provided in the Appendix below).
+
+ "Derivative Works" shall mean any work, whether in Source or Object
+ form, that is based on (or derived from) the Work and for which the
+ editorial revisions, annotations, elaborations, or other modifications
+ represent, as a whole, an original work of authorship. For the purposes
+ of this License, Derivative Works shall not include works that remain
+ separable from, or merely link (or bind by name) to the interfaces of,
+ the Work and Derivative Works thereof.
+
+ "Contribution" shall mean any work of authorship, including
+ the original version of the Work and any modifications or additions
+ to that Work or Derivative Works thereof, that is intentionally
+ submitted to Licensor for inclusion in the Work by the copyright owner
+ or by an individual or Legal Entity authorized to submit on behalf of
+ the copyright owner. For the purposes of this definition, "submitted"
+ means any form of electronic, verbal, or written communication sent
+ to the Licensor or its representatives, including but not limited to
+ communication on electronic mailing lists, source code control systems,
+ and issue tracking systems that are managed by, or on behalf of, the
+ Licensor for the purpose of discussing and improving the Work, but
+ excluding communication that is conspicuously marked or otherwise
+ designated in writing by the copyright owner as "Not a Contribution."
+
+ "Contributor" shall mean Licensor and any individual or Legal Entity
+ on behalf of whom a Contribution has been received by Licensor and
+ subsequently incorporated within the Work.
+
+ 2. Grant of Copyright License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ copyright license to reproduce, prepare Derivative Works of,
+ publicly display, publicly perform, sublicense, and distribute the
+ Work and such Derivative Works in Source or Object form.
+
+ 3. Grant of Patent License. Subject to the terms and conditions of
+ this License, each Contributor hereby grants to You a perpetual,
+ worldwide, non-exclusive, no-charge, royalty-free, irrevocable
+ (except as stated in this section) patent license to make, have made,
+ use, offer to sell, sell, import, and otherwise transfer the Work,
+ where such license applies only to those patent claims licensable
+ by such Contributor that are necessarily infringed by their
+ Contribution(s) alone or by combination of their Contribution(s)
+ with the Work to which such Contribution(s) was submitted. If You
+ institute patent litigation against any entity (including a
+ cross-claim or counterclaim in a lawsuit) alleging that the Work
+ or a Contribution incorporated within the Work constitutes direct
+ or contributory patent infringement, then any patent licenses
+ granted to You under this License for that Work shall terminate
+ as of the date such litigation is filed.
+
+ 4. Redistribution. You may reproduce and distribute copies of the
+ Work or Derivative Works thereof in any medium, with or without
+ modifications, and in Source or Object form, provided that You
+ meet the following conditions:
+
+ (a) You must give any other recipients of the Work or
+ Derivative Works a copy of this License; and
+
+ (b) You must cause any modified files to carry prominent notices
+ stating that You changed the files; and
+
+ (c) You must retain, in the Source form of any Derivative Works
+ that You distribute, all copyright, patent, trademark, and
+ attribution notices from the Source form of the Work,
+ excluding those notices that do not pertain to any part of
+ the Derivative Works; and
+
+ (d) If the Work includes a "NOTICE" text file as part of its
+ distribution, then any Derivative Works that You distribute must
+ include a readable copy of the attribution notices contained
+ within such NOTICE file, excluding those notices that do not
+ pertain to any part of the Derivative Works, in at least one
+ of the following places: within a NOTICE text file distributed
+ as part of the Derivative Works; within the Source form or
+ documentation, if provided along with the Derivative Works; or,
+ within a display generated by the Derivative Works, if and
+ wherever such third-party notices normally appear. The contents
+ of the NOTICE file are for informational purposes only and
+ do not modify the License. You may add Your own attribution
+ notices within Derivative Works that You distribute, alongside
+ or as an addendum to the NOTICE text from the Work, provided
+ that such additional attribution notices cannot be construed
+ as modifying the License.
+
+ You may add Your own copyright statement to Your modifications and
+ may provide additional or different license terms and conditions
+ for use, reproduction, or distribution of Your modifications, or
+ for any such Derivative Works as a whole, provided Your use,
+ reproduction, and distribution of the Work otherwise complies with
+ the conditions stated in this License.
+
+ 5. Submission of Contributions. Unless You explicitly state otherwise,
+ any Contribution intentionally submitted for inclusion in the Work
+ by You to the Licensor shall be under the terms and conditions of
+ this License, without any additional terms or conditions.
+ Notwithstanding the above, nothing herein shall supersede or modify
+ the terms of any separate license agreement you may have executed
+ with Licensor regarding such Contributions.
+
+ 6. Trademarks. This License does not grant permission to use the trade
+ names, trademarks, service marks, or product names of the Licensor,
+ except as required for reasonable and customary use in describing the
+ origin of the Work and reproducing the content of the NOTICE file.
+
+ 7. Disclaimer of Warranty. Unless required by applicable law or
+ agreed to in writing, Licensor provides the Work (and each
+ Contributor provides its Contributions) on an "AS IS" BASIS,
+ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
+ implied, including, without limitation, any warranties or conditions
+ of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
+ PARTICULAR PURPOSE. You are solely responsible for determining the
+ appropriateness of using or redistributing the Work and assume any
+ risks associated with Your exercise of permissions under this License.
+
+ 8. Limitation of Liability. In no event and under no legal theory,
+ whether in tort (including negligence), contract, or otherwise,
+ unless required by applicable law (such as deliberate and grossly
+ negligent acts) or agreed to in writing, shall any Contributor be
+ liable to You for damages, including any direct, indirect, special,
+ incidental, or consequential damages of any character arising as a
+ result of this License or out of the use or inability to use the
+ Work (including but not limited to damages for loss of goodwill,
+ work stoppage, computer failure or malfunction, or any and all
+ other commercial damages or losses), even if such Contributor
+ has been advised of the possibility of such damages.
+
+ 9. Accepting Warranty or Additional Liability. While redistributing
+ the Work or Derivative Works thereof, You may choose to offer,
+ and charge a fee for, acceptance of support, warranty, indemnity,
+ or other liability obligations and/or rights consistent with this
+ License. However, in accepting such obligations, You may act only
+ on Your own behalf and on Your sole responsibility, not on behalf
+ of any other Contributor, and only if You agree to indemnify,
+ defend, and hold each Contributor harmless for any liability
+ incurred by, or claims asserted against, such Contributor by reason
+ of your accepting any such warranty or additional liability.
+
+ END OF TERMS AND CONDITIONS
+
+ APPENDIX: How to apply the Apache License to your work.
+
+ To apply the Apache License to your work, attach the following
+ boilerplate notice, with the fields enclosed by brackets "[]"
+ replaced with your own identifying information. (Don't include
+ the brackets!) The text should be enclosed in the appropriate
+ comment syntax for the file format. We also recommend that a
+ file or class name and description of purpose be included on the
+ same "printed page" as the copyright notice for easier
+ identification within third-party archives.
+
+ Copyright [yyyy] [name of copyright owner]
+
+ 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.
+
+
+
diff --git a/capi-content-media-content.pc.in b/capi-content-media-content.pc.in new file mode 100644 index 0000000..7f9c91f --- /dev/null +++ b/capi-content-media-content.pc.in @@ -0,0 +1,15 @@ + +# Package Information for pkg-config + +prefix=@PREFIX@ +exec_prefix=/usr +libdir=/usr/lib +includedir=/usr/include/media-content + +Name: @PC_NAME@ +Description: @PACKAGE_DESCRIPTION@ +Version: @VERSION@ +Requires: @PC_REQUIRED@ +Libs: -L${libdir} @PC_LDFLAGS@ +Cflags: -I${includedir} @PC_CFLAGS@ + diff --git a/debian/README b/debian/README new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/debian/README diff --git a/debian/capi-content-media-content-dev.install b/debian/capi-content-media-content-dev.install new file mode 100644 index 0000000..761a28b --- /dev/null +++ b/debian/capi-content-media-content-dev.install @@ -0,0 +1,4 @@ +/usr/include/* +/usr/include/*/* +/usr/lib/pkgconfig/*.pc + diff --git a/debian/capi-content-media-content-dev.postinst b/debian/capi-content-media-content-dev.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-content-media-content-dev.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/capi-content-media-content.install b/debian/capi-content-media-content.install new file mode 100644 index 0000000..4a755a4 --- /dev/null +++ b/debian/capi-content-media-content.install @@ -0,0 +1 @@ +/usr/lib/lib*.so* diff --git a/debian/capi-content-media-content.postinst b/debian/capi-content-media-content.postinst new file mode 100644 index 0000000..1a24852 --- /dev/null +++ b/debian/capi-content-media-content.postinst @@ -0,0 +1 @@ +#!/bin/sh diff --git a/debian/changelog b/debian/changelog new file mode 100644 index 0000000..374db7c --- /dev/null +++ b/debian/changelog @@ -0,0 +1,15 @@ +capi-content-media-content (0.1.0-10) unstable; urgency=low + + * Update the version. + + -- Dongyoung Kim <dydot1.kim@samsung.com> Thu, 15 Dec 2011 13:38:10 +0900 + + +capi-content-media-content (0.0.1-1) unstable; urgency=low + + + * Initial release. + + + -- Dongyoung Kim <dydot1.kim@samsung.com> Wed, 07 Dec 2011 12:46:25 +0900 + diff --git a/debian/compat b/debian/compat new file mode 100644 index 0000000..7ed6ff8 --- /dev/null +++ b/debian/compat @@ -0,0 +1 @@ +5 diff --git a/debian/control b/debian/control new file mode 100644 index 0000000..51b48fe --- /dev/null +++ b/debian/control @@ -0,0 +1,23 @@ +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 + +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 +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}) +Description: A Media content library in Tizen Native API (DBG) + diff --git a/debian/rules b/debian/rules new file mode 100755 index 0000000..c1aedf9 --- /dev/null +++ b/debian/rules @@ -0,0 +1,65 @@ +#!/usr/bin/make -f + +CFLAGS = -Wall -g + +ifneq (,$(findstring noopt,$(DEB_BUILD_OPTIONS))) + CFLAGS += -O0 +else + CFLAGS += -O2 +endif +CMAKE_ROOT_DIR ?= $(CURDIR) +CMAKE_BUILD_DIR ?= $(CURDIR)/cmake_build_tmp + +configure: configure-stamp +configure-stamp: + dh_testdir + mkdir -p $(CMAKE_BUILD_DIR) && cd $(CMAKE_BUILD_DIR) && cmake .. + touch configure-stamp + + +build: build-stamp +build-stamp: configure-stamp + dh_testdir + cd $(CMAKE_BUILD_DIR) && $(MAKE) + touch $@ + +clean: + cd $(CMAKE_ROOT_DIR) + dh_testdir + dh_testroot + rm -f build-stamp configure-stamp + rm -f `find . -name *.pc` + rm -rf $(CMAKE_BUILD_DIR) + dh_clean + +install: build + dh_testdir + dh_testroot + dh_clean -k + dh_installdirs + + cd $(CMAKE_BUILD_DIR) && $(MAKE) DESTDIR=$(CURDIR)/debian/tmp install + +binary-indep: build install + +binary-arch: build install + dh_testdir + dh_testroot + dh_installchangelogs + dh_installdocs + dh_installexamples + dh_install --sourcedir=debian/tmp + dh_installman + dh_link + dh_strip --dbg-package=capi-content-media-content-dbg + dh_fixperms + dh_makeshlibs + dh_installdeb + dh_shlibdeps + dh_gencontrol + dh_md5sums + dh_builddeb + +binary: binary-indep binary-arch +.PHONY: build clean binary-indep binary-arch binary install configure + diff --git a/include/media_audio.h b/include/media_audio.h new file mode 100644 index 0000000..7208a86 --- /dev/null +++ b/include/media_audio.h @@ -0,0 +1,1022 @@ +/* +* 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_AUDIO_META_H__ +#define __TIZEN_AUDIO_META_H__ + +#include <media_content_type.h> + + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * @addtogroup CAPI_CONTENT_MEDIA_AUDIO_META_MODULE + * @{ + * + * @file audio_meta.h + * @brief This file contains the audio metadata API and related structure and enumeration. \n + * Description of the audio content involves: album, artist, author, genre and description tags. \n + * Parameters of the recording are also supported, as: format, bitrate, duration, size etc. + */ + + +/** + * @brief Destroys audio metadata. + * + * @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 + * @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. + * + * @remark The destination handle must be released with audio_meta_destroy() by you. + * + * @param [out] dst A destination handle to audio metadata + * @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 + * @see audio_meta_destroy() + */ +int audio_meta_clone(audio_meta_h* dst, audio_meta_h src); + + +/** + * @brief Gets name of genre of given audio metadata. + * + * @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 Not enough memory is available + */ +int audio_meta_get_genre(audio_meta_h audio, char **genre_name); + + +/** + * @brief Gets name of album of given audio metadata. + * + * @remarks @a album_name must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_album(audio_meta_h audio, char **album_name); + + +/** + * @brief Gets name of artist of given audio metadata. + * + * @remarks @a artist_name must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_artist(audio_meta_h audio, char **artist_name); + + +/** + * @brief Gets name of author of given audio metadata. + * + * @remarks @a author_name must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_author(audio_meta_h audio, char **author_name); + + +/** + * @brief Gets year of given audio metadata. + * + * @remarks @a year must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_year(audio_meta_h audio, char** year); + + +/** + * @brief Gets copyright notice of given audio metadata. + * + * @remarks @a copyright must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_copyright(audio_meta_h audio, char **copyright); + + +/** + * @brief Gets description of given audio metadata. + * + * @remarks @a description must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @param [out] description The audio description + * @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_meta_get_description(audio_meta_h audio, char **description); + + +/** + * @brief Gets format of given audio metadata. + * + * @remarks @a format must be released with free() by you. + * + * @param [in] audio The handle to audio metadata + * @param [out] format The audio format + * @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_meta_get_format(audio_meta_h audio, char **format); + + +/** + * @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]. + * @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_bitrate(audio_meta_h audio, int *bitrate); + + +/** + * @brief Gets track number of given audio metadata. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_track_num(audio_meta_h audio, int *track_num); + + +/** + * @brief Gets track duration of given audio metadata. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_duration(audio_meta_h audio, int *duration); + + +/** + * @brief Gets track rating of given audio metadata. + * + * @param [in] audio The handle to audio metadata + * @param [out] rating The rating 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 + */ +int audio_meta_get_rating(audio_meta_h audio, int *rating); + + +/** + * @brief Gets number which represents how many times given audio has been played. + * + * @param [in] audio The handle to audio metadata + * @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 + */ +int audio_meta_get_count_played(audio_meta_h audio, int *count_played); + + +/** + * @brief Gets the audio's played time parameter. + * @details Function returns audio's elapsed playback time parameter as period + * 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 + * @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_played(audio_meta_h audio, int *time_played); + + +/** + * @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. + * + * @param [in] audio The handle to audio metadata + * @param [out] size The size of audio file in bytes. + * @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_size(audio_meta_h audio, int *size); + + +/** + * @brief Gets audio's category from desired audio metadata. + * + * @param [in] audio The handle to audio metadata + * @param [out] category The audio category + * @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_category(audio_meta_h audio, audio_category_e *category); + + +/** + * @brief Updates audio's played counter to the media database. + * + * @param [in] audio The handle to audio metadata + * @param [in] count The new 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 + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + */ +int audio_meta_update_count_played_to_db(audio_meta_h audio, int count); + +/** + * @brief Updates audio's played time parameter to the media database. + * + * @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 + * @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() + * + */ +int audio_playlist_delete_from_db(audio_playlist_h playlist); + +/** + * @brief Gets number of media info for the given playlist present in 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() + * + */ +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 + * @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_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); + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif + + +#endif /*__TIZEN_AUDIO_META_H__*/ diff --git a/include/media_content.h b/include/media_content.h new file mode 100644 index 0000000..133b41f --- /dev/null +++ b/include/media_content.h @@ -0,0 +1,77 @@ +/*
+* 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__ */
+
+
diff --git a/include/media_content_type.h b/include/media_content_type.h new file mode 100755 index 0000000..7849214 --- /dev/null +++ b/include/media_content_type.h @@ -0,0 +1,454 @@ +/*
+* 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 = 0x01 << 0, /**< The device's internal storage */
+ MEDIA_CONTENT_STORAGE_EXTERNAL = 0x01 << 1, /**< 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 searchabe 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 searchabe type of playlist */
+ MEDIA_AUDIO_SEARCH_BY_ARTIST = 0x01 << 1, /**< The searchabe type of artist */
+ MEDIA_AUDIO_SEARCH_BY_ALBUM = 0x01 << 2, /**< The searchabe type of album */
+ MEDIA_AUDIO_SEARCH_BY_AUTHOR = 0x01 << 3, /**< The searchabe type of author */
+ MEDIA_AUDIO_SEARCH_BY_GENRE = 0x01 << 4, /**< The searchabe 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 searchabe type folder name */
+}media_tag_search_type_e;
+
+
+
+
+
+/**
+ * @ingroup CAPI_CONTENT_MEDIA_FILTER_INFO_MODULE
+ * @brief The handle to media infon 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 hande 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__*/
diff --git a/include/media_filter.h b/include/media_filter.h new file mode 100644 index 0000000..400e968 --- /dev/null +++ b/include/media_filter.h @@ -0,0 +1,729 @@ +/*
+* 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__ */
+
diff --git a/include/media_folder.h b/include/media_folder.h new file mode 100644 index 0000000..e1f48bb --- /dev/null +++ b/include/media_folder.h @@ -0,0 +1,192 @@ +/*
+* 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 modifed date of the folder.
+ *
+ * @param[in] folder The handle to media folder
+ * @param[out] date The modifed 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__ */
+
diff --git a/include/media_image.h b/include/media_image.h new file mode 100644 index 0000000..ab9b16d --- /dev/null +++ b/include/media_image.h @@ -0,0 +1,167 @@ +/* +* 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_IMAGE_META_H__ +#define __TIZEN_IMAGE_META_H__ + +#include <media_content_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_IMAGE_MODULE + * @{ + */ + +/** + * @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. + * + * @param [out] dst A destination handle to image metadata + * @param [in] src The source handle to image 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 + * @see image_meta_destroy() + */ +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 + * no longer can be used to perform any operation. A new handle has to + * be created before next usage. + * + * @param [in] image The handle to image metadata + * @return 0 on success, otherwise a negative error value. + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @pre Get copy of image_meta handle by calling image_meta_clone() + * @see image_meta_clone() + */ +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. + * + * @param [in] image The handle to image metadata + * @param [out] longitude The image longitude in degrees + * @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); + + +/** + * @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. + * + * @param [in] image The handle to image metadata + * @param [out] latitude The image latitude in degrees + * @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); + + +/** + * @brief Gets the image description. + * + * @remarks @a description must be released with free() by you. + * + * @param [in] image The handle to image metadata + * @param [out] description The image description or NULL + * @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); + + +/** + * @brief Gets image's width in pixels. + * + * @param [in] image The handle to image metadata + * @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_width(image_meta_h image, int *width); + + +/** + * @brief Gets image's height in pixels. + * + * @param [in] image The handle to image metadata + * @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 + */ +int image_meta_get_height(image_meta_h image, int *height); + + +/** + * @brief Gets the image orientation. + * + * @param [in] image The handle to image metadata + * @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_orientation(image_meta_h image, media_content_orientation_e *orientation); + + +/** + * @brief Gets the date, when image was created as time_t structure. + * + * @param [in] image The handle to image metadata + * @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_date_taken(image_meta_h image, time_t *date_taken); + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__TIZEN_IMAGE_META_H__*/ diff --git a/include/media_info.h b/include/media_info.h new file mode 100644 index 0000000..a8faa91 --- /dev/null +++ b/include/media_info.h @@ -0,0 +1,306 @@ +/* +* 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_INFORMATION_H__ +#define __TIZEN_MEDIA_INFORMATION_H__ + +#include <media_content_type.h> + + + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_INFO_MODULE + * @{ + */ + +/** + * @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. + * @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_info_foreach_media_from_db(media_info_filter_h filter, media_info_cb callback, void *user_data); + + + +/** + * @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] 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 + */ +int media_info_foreach_tag_from_db(media_info_h media, media_tag_cb callback, void *user_data); + + + +/** + * @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 Destroys the media info. + * @details The function frees all resources related to the meida 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 Gets path to media info. + * + * @remarks @a path must be released with free() by you. + * + * @param[in] media The handle to media info + * @param[out] path The path 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_OUT_OF_MEMORY Out of memory + * + */ +int media_info_get_file_path(media_info_h media, char **path); + +/** + * @brief Gets name to media info. + * + * @remarks @a name must be released with free() by you. + * + * @param[in] media The handle to media info + * @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_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_display_name(media_info_h media, char **name); + +/** + * @brief Gets the thumbnail to media info. + * + * @remarks @a path must be released with free() by you. + * + * @param[in] media The handle to media info + * @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_INVALID_PARAMETER Invalid parameter + * + */ +int media_info_get_thumbnail_path(media_info_h media, char **path); + +/** + * @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_date_modified(media_info_h media, time_t *time); + +/** + * @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). \n + * @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); + + + +/** + * @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. + * + * @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 + * @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); + +/** + * @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. + * + * @remark The @a video handle must be released with video_meta_destroy() by you. + * + * @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 + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see video_meta_destroy() + * + */ +int media_info_get_video_from_db(media_info_h media, video_meta_h* video); + +/** + * @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. + * + * @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 + * @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() + */ +int media_info_get_audio_from_db(media_info_h media, audio_meta_h* audio); + + +/** + * @brief Gets the given media info's favorite status. + * + * @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, int* favorite); + + +/** + * @brief Updates media info's favorite status to the media database. + * + * @param [in] media The handle to media info + * @param [in] 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 + * @pre This function requires opened connection to content service by media_content_connect(). + * @see media_content_connect() + * @see media_info_meta_get_favorite() + */ +int media_info_update_favorite_to_db(media_info_h media, int favorite); + + + +/** + * @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. + * + * @param[in] type The type of media content + * @param[in] path The path 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_insert_to_db(media_content_type_e type, const char *path); + + + + +/** + * @} + */ + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /* __TIZEN_MEDIA_INFORMATION_H__ */ + diff --git a/include/media_info_private.h b/include/media_info_private.h new file mode 100644 index 0000000..758d60b --- /dev/null +++ b/include/media_info_private.h @@ -0,0 +1,313 @@ +/* +* 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_INFO_PRIVATE_H__ +#define __TIZEN_MEDIA_INFO_PRIVATE_H__ + + +#include <media_content_type.h> +#include <string.h> +#include <sqlite3.h> +#include <stdlib.h> +#include <stdio.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +#define MEDIA_CONTENT_TYPE 5 + +#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 */ + +#define MAX_QUERY_SIZE 4096 +#define MIN_QUERY_SIZE 256 +#define DEFAULT_QUERY_SIZE 1024 +#define MAX_KEYWORD_SIZE 2048 + + + +typedef struct +{ + 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; + + +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; + + +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; + +typedef struct +{ + int offset; // position of start + int count; // offset + media_content_order_e order; //The sort order + +}video_bookmark_filter_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; + +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; + + +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; + int width; + int height; + int favorite; + media_content_orientation_e orientation; + time_t date_taken; +}image_meta_s; + + +typedef struct +{ + char* video_id; + int longitude; + int latitude; + char* album; + char* artist; + char* title; + char* description; + char* thumbnail; + int time_played; + int duration; + int width; + int height; + int favorite; + media_content_orientation_e orientation; + time_t date_taken; +}video_meta_s; + + +typedef struct +{ + int bookmark_id; + char* video_id; + time_t time_marked; + char* thumbnail; + +}video_bookmark_s; + + +typedef struct +{ + char* audio_id; + char* genre; + char* author; + char* album; + char* artist; + char* year; + char* copyright; + char* description; + char* format; + int bitrate; + int track_num; + int duration; + int rating; + int count_played; + int time_played; + time_t time_added; + int size; + int category; + +}audio_meta_s; + +typedef struct +{ + int playlist_id; //playlist id + char* name; // playlist name + +}audio_playlist_s; + + +typedef struct +{ + char* name; +}audio_artist_s; + +typedef struct +{ + char* name; +}audio_genre_s; + + +typedef struct +{ + char* name; +}audio_author_s; + +typedef struct +{ + char* name; +}audio_album_s; + + + + + +#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_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 uuid, path, name, storage_type,modified_date from (select uuid, path, folder_name as name, storage_type,modified_date from visual_folder where valid=1 union select _id, 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.media_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 media_uuid, tag_id from visual_tag_map ) tm, ( select uuid, folder_uuid, display_name, modified_date from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=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_id 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_id ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_id 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_id ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_id from audio_media where valid=1 and album='%s'" +#define SELECT_MEDIA_COUNT_FROM_ALBUM "select count(*) from audio_media where valid=1 and genre='%s'" +#define SELECT_AUTHOR_LIST "select distinct author as name from audio_media where valid=1 " +#define SELECT_MEDIA_FROM_AUTHOR "select audio_id ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_id from audio_media where valid=1 and author='%s'" +#define SELECT_MEDIA_COUNT_FROM_AUTHOR "select count(*) from audio_media where valid=1 and genre='%s'" +#define SELECT_MEDIA_ARTIST_LIST "select distinct artist as name from audio_media where valid=1" +#define SELECT_MEDIA_FROM_ARTIST "select audio_id ,path ,title as display_name,thumbnail_path,modified_date, content_type, favourite,valid,folder_id from audio_media where valid=1 and artist='%s'" +#define SELECT_MEDIA_COUNT_FROM_ARTIST "select count(*) from audio_media where valid=1 and genre='%s'" +#define SELECT_BOOKMARK_FROM_VIDEO "select _id,media_uuid,marked_time,thumbnail_path from video_bookmark where media_uuid='%s' " + + +/** + *@internal + */ +void _content_folder_get_detail(sqlite3_stmt *stmt, media_folder_h folder); + +/** + *@internal + */ +int _content_query_prepare(sqlite3_stmt **stmt, char *select_query,char *condition_query, char *search_query, char *limit_query,char *order ); + + +/** + *@internal + */ +void _content_item_get_detail(sqlite3_stmt *stmt, media_info_h item); + +/** + *@internal + */ +int _content_error_capi(media_content_type_e type, int cotent_error); + +/** + *@internal + */ +int _content_get_storage_type(const char* full_path); + +/** + *@internal + */ +int _content_get_audio_category(const char* file_full_path,int* category); + +/** + *@internal + */ +int _content_query_sql(char *query_str); + + +#ifdef __cplusplus +} +#endif /* __cplusplus */ +#endif /*__TIZEN_MEDIA_INFO_PRIVATE_H__*/ + + + diff --git a/include/media_tag.h b/include/media_tag.h new file mode 100755 index 0000000..e334119 --- /dev/null +++ b/include/media_tag.h @@ -0,0 +1,228 @@ +/*
+* 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__ */
+
+
diff --git a/include/media_video.h b/include/media_video.h new file mode 100644 index 0000000..2fc4021 --- /dev/null +++ b/include/media_video.h @@ -0,0 +1,394 @@ +/* +* 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_VIDEO_META_H__ +#define __TIZEN_VIDEO_META_H__ + +#include <media_content_type.h> + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + + +/** + * @addtogroup CAPI_CONTENT_MEDIA_VIDEO_META_MODULE + * @{ + */ + +/** + * @brief Clones video metadata. + * @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. + * + * @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 + * @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 + * no longer can be used to perform any operation. A new handle has to + * be created before the next use. + * + * @param [in] video The 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 + * @pre Get copy of video metadata handle by calling video_meta_clone() + * @see video_meta_clone() + * + */ +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. + * + * @param [in] video The handle to video metadata + * @param [out] longitude The video longitude in degrees + * @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_longitude(video_meta_h video, double *longitude); + + +/** + * @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. + * + * @param [in] video The handle to video metadata + * @param [out] latitude The video latitude in degrees + * @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_latitude(video_meta_h video, double *latitude); + + +/** + * @brief Gets the video's album. + * + * @remarks @a album must be released with free() by you. + * + * @param [in] video The handle to video metadata + * @param [out] album The video album or NULL + * @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_album(video_meta_h video, char **album); + + +/** + * @brief Gets the video's artist. + * + * @remarks @a artist must be released with free() by you. + * + * @param [in] video The handle to video metadata + * @param [out] artist The artist 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_artist(video_meta_h video, char **artist); + + +/** + * @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] 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_title(video_meta_h video, char **title); + + +/** + * @brief Gets the video's description. + * + * @remarks @a description must be released with free() by you. + * + * @param [in] video The handle to video metadata + * @param [out] description The description 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); + + +/** + * @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. + * + * @param [in] video The handle to video metadata + * @param [out] time_played The time period 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 + * @see video_meta_update_time_played_to_db() + */ +int video_meta_get_time_played(video_meta_h video, int *time_played); + + +/** + * @brief Gets duration of video metadata. + * + * @param [in] video The handle to video metadata + * @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_duration(video_meta_h video, int *duration); + + +/** + * @brief Gets the video's width in pixels. + * + * @param [in] video The handle to video metadata + * @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 + */ +int video_meta_get_width(video_meta_h video, int *width); + + +/** + * @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 Gets the video's orientation. + * + * @param [in] video The handle to video metadata + * @param [out] orientation The orientation 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 + */ +int video_meta_get_orientation(video_meta_h video, media_content_orientation_e *orientation); + + +/** + * @brief Gets the date, when video was created + * + * @param [in] video The handle to video metadata + * @param [out] date_taken The date, when video 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 video_meta_get_date_taken(video_meta_h video, time_t *date_taken); + + +/** + * @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. + * + * @param [in] video The handle to video metadata + * @param [in] time_played The video time played (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_meta_get_time_played() + */ +int video_meta_update_time_played_to_db(video_meta_h video, int time_played); + + +/** + *@} + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_VIDEO_BOOKMARK_MODULE + * @{ + */ + + +/** + * @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, + * beacuse searching by bookmark name information is not supported. + * + * @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 + + * @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); + + +/** + * @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. + * + * @param [out] dst A destination handle to video bookmark + * @param [in] src The source handle to video 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 video_bookmark_destroy() + * @see video_bookmark_foreach_bookmark_from_db() + * + */ +int video_bookmark_clone(video_bookmark_h *dst, video_bookmark_h src); + + +/** + * @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. + * + * @param [in] bookmark The handle to video 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 video_bookmark_clone() + * @see video_bookmark_clone() + */ +int video_bookmark_destroy(video_bookmark_h bookmark); + + +/** + * @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 video bookmark + * @param [out] time_marked 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 video_bookmark_get_time_marked(video_bookmark_h bookmark, time_t *time_marked); + + +/** + * @brief Gets the video bookmark's thumbnail + * + * @remarks thumbnail must be released with free() by you. + * + * @param [in] bookmark The handle to video bookmark + * @param [out] thumbnail_path The thumbnail path of video 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 video_bookmark_get_thumbnail_path(video_bookmark_h bookmark, char **thumbnail_path); + + +/** + * @brief Inserts a new bookmark in video on specified time offset to the media database. + * + * @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. + * @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() + * + */ +int video_bookmark_insert_to_db(video_meta_h video, time_t time, const char *thumbnail_path); + + +/** + * @brief Removes video bookmark from the media database. + * + * @param [in] bookmark The handle to video 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 video_bookmark_insert_to_db() + * + */ +int video_bookmark_delete_from_db(video_bookmark_h bookmark); + + + +/** + * @} + */ + +#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 new file mode 100644 index 0000000..9143ecd --- /dev/null +++ b/packaging/capi-content-media-content.spec @@ -0,0 +1,53 @@ +Name: capi-content-media-content +Summary: A Media content library in SLP C API +Version: 0.0.1 +Release: 1 +Group: TO_BE/FILLED_IN +License: TO BE FILLED IN +Source0: %{name}-%{version}.tar.gz +BuildRequires: cmake +BuildRequires: pkgconfig(dlog) +BuildRequires: pkgconfig(libmedia-service) +BuildRequires: pkgconfig(drm-service) +BuildRequires: pkgconfig(aul) +BuildRequires: pkgconfig(capi-base-common) +Requires(post): /sbin/ldconfig +Requires(postun): /sbin/ldconfig + +%description + + +%package devel +Summary: A Media content library in Tizen Native API (Development) +Group: TO_BE/FILLED_IN +Requires: %{name} = %{version}-%{release} + +%description devel + +%prep +%setup -q + + +%build +cmake . -DCMAKE_INSTALL_PREFIX=/usr + + +make %{?jobs:-j%jobs} + +%install +rm -rf %{buildroot} +%make_install + +%post -p /sbin/ldconfig + +%postun -p /sbin/ldconfig + + +%files +%{_libdir}/libcapi-content-media-content.so + +%files devel +%{_includedir}/media-content/*.h +%{_libdir}/pkgconfig/*.pc + + diff --git a/src/media_audio.c b/src/media_audio.c new file mode 100644 index 0000000..db6ee70 --- /dev/null +++ b/src/media_audio.c @@ -0,0 +1,2540 @@ +/*
+* 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-error.h>
+#include <media-svc-error.h>
+#include <media-info.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->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(_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(_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(_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(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(_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(_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(_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(_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;
+}
+
diff --git a/src/media_content.c b/src/media_content.c new file mode 100644 index 0000000..5f6dfad --- /dev/null +++ b/src/media_content.c @@ -0,0 +1,192 @@ +/*
+* 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 <media-info-error.h>
+#include <media-svc-error.h>
+#include <minfo-types.h>
+#include <minfo-api.h>
+#include <media-info.h>
+
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_MEDIACONTENT"
+
+static sqlite3* db_handle;
+
+
+
+
+int media_content_connect()
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ int _ret;
+ _ret = mediainfo_connect_db_with_handle(&db_handle);
+
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE,_ret);
+ if( ret == MEDIA_CONTENT_ERROR_NONE)
+ {
+ _ret = mediainfo_open();
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE,_ret);
+ }
+ return ret;
+}
+
+
+int media_content_disconnect()
+{
+ int ret = MEDIA_CONTENT_ERROR_NONE;
+ int _ret;
+
+ if(db_handle != NULL)
+ {
+ _ret = mediainfo_disconnect_db_with_handle(db_handle);
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE,_ret);
+ if( ret == MEDIA_CONTENT_ERROR_NONE)
+ {
+ _ret = mediainfo_close();
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE,_ret);
+ db_handle = NULL;
+ }
+ }
+
+ return ret;
+}
+
+
+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(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(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;
+}
+
+
diff --git a/src/media_filter.c b/src/media_filter.c new file mode 100644 index 0000000..2995884 --- /dev/null +++ b/src/media_filter.c @@ -0,0 +1,1137 @@ +/*
+* 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 <media-info-error.h>
+#include <media-svc-error.h>
+#include <minfo-types.h>
+#include <minfo-api.h>
+#include <media-info.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;
+
+}
+
diff --git a/src/media_folder.c b/src/media_folder.c new file mode 100644 index 0000000..2b85b3c --- /dev/null +++ b/src/media_folder.c @@ -0,0 +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 <media-info-error.h>
+#include <media-svc-error.h>
+#include <minfo-types.h>
+#include <minfo-api.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);
+}
+
+
diff --git a/src/media_image.c b/src/media_image.c new file mode 100644 index 0000000..347b941 --- /dev/null +++ b/src/media_image.c @@ -0,0 +1,259 @@ +/* +* 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_image.h> +#include <media_content.h> +#include <media_info_private.h> +#include <media-info-error.h> +#include <media-svc-error.h> +#include <minfo-types.h> +#include <minfo-api.h> +#include <media-info.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; + if(_image) + { + if(_image->image_id) + free(_image->image_id); + if(_image->thumbnail) + free(_image->thumbnail); + if(_image->description) + free(_image->description); + + free(_image); + 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 image_meta_clone(image_meta_h* dst, image_meta_h src) +{ + int ret; + image_meta_s* _src = (image_meta_s*)src; + + if(_src != NULL) + { + + 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); + 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; + +} + +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; + } + + return ret; + +} +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); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; + +} + +int image_meta_get_description(image_meta_h image, char** description) +{ + int ret; + image_meta_s* _image = (image_meta_s*)image; + if(_image && description) + { + if((_image->description != NULL) && (strlen(_image->description) > 0)) + { + *description = strdup(_image->description); + if (NULL == *description) + { + 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 image_meta_get_width(image_meta_h image, int* width) +{ + int ret; + image_meta_s* _image = (image_meta_s*)image; + if(_image && width) + { + *width = _image->width; + 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 image_meta_get_height(image_meta_h image, int* height) +{ + int ret; + image_meta_s* _image = (image_meta_s*)image; + if(_image && height) + { + *height = _image->height; + 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 image_meta_get_orientation(image_meta_h image, media_content_orientation_e* orientation) +{ + int ret; + image_meta_s* _image = (image_meta_s*)image; + if(_image) + { + *orientation = _image->orientation; + 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 image_meta_get_date_taken(image_meta_h image,time_t* date_taken) +{ + int ret; + image_meta_s* _image = (image_meta_s*)image; + if(_image && date_taken) + { + *date_taken = _image->date_taken; + 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; + +} + + diff --git a/src/media_info.c b/src/media_info.c new file mode 100644 index 0000000..8dcb895 --- /dev/null +++ b/src/media_info.c @@ -0,0 +1,1028 @@ +/*
+* 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-info-error.h>
+#include <media-svc-error.h>
+#include <media-info.h>
+#include <audio-svc.h>
+#include <audio-svc-error.h>
+#include <audio-svc-types.h>
+
+#include <media-svc-error.h>
+#include <minfo-types.h>
+#include <minfo-api.h>
+#include <media-info.h>
+
+#include <drm-service.h>
+#include <aul.h>
+
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_MEDIACONTENT"
+
+
+#define SELECT_AUDIO_FROM_MEDIA "select audio_id,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_id='%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 media_uuid, tag_id from visual_tag_map where media_uuid='%s' ) tm, ( select uuid, folder_uuid from visual_media) m, ( select uuid, lock_status from visual_folder where valid=1 ) f where tm.tag_id = t._id and m.uuid = tm.media_uuid and m.folder_uuid = f.uuid and f.lock_status=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(path, _type);
+ ret = _content_error_capi(MEDIA_CONTENT_TYPE, ret);
+ break;
+ case MEDIA_CONTENT_TYPE_VIDEO:
+ _type = MINFO_ITEM_VIDEO;
+ ret = minfo_add_media(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(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( AUDIO_SVC_FAVORITE_LIST_ID, _media->item_id);
+ }
+ else
+ {
+ ret = audio_svc_remove_item_from_playlist_by_audio_id(AUDIO_SVC_FAVORITE_LIST_ID, _media->item_id);
+ }
+ }
+ else
+ {
+ ret = minfo_update_media_favorite(_media->item_id,favorite);
+ }
+ 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 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_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_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(_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(_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(_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(_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 soun 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;
+
+
+
+}
+
diff --git a/src/media_tag.c b/src/media_tag.c new file mode 100644 index 0000000..c8d1850 --- /dev/null +++ b/src/media_tag.c @@ -0,0 +1,539 @@ +/*
+* 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 <media-info-error.h>
+#include <media-svc-error.h>
+#include <minfo-types.h>
+#include <minfo-api.h>
+#include <dlog.h>
+
+#ifdef LOG_TAG
+#undef LOG_TAG
+#endif
+
+#define LOG_TAG "TIZEN_N_MEDIACONTENT"
+
+
+
+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(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(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(_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 media_id=%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(_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(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;
+}
+
diff --git a/src/media_video.c b/src/media_video.c new file mode 100644 index 0000000..b8bc8c3 --- /dev/null +++ b/src/media_video.c @@ -0,0 +1,741 @@ +/* +* 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-info-error.h> +#include <media-svc-error.h> +#include <minfo-types.h> +#include <minfo-api.h> +#include <media-info.h> + +#include <dlog.h> + +#ifdef LOG_TAG +#undef LOG_TAG +#endif + +#define LOG_TAG "TIZEN_N_MEDIACONTENT" + + +int video_meta_destroy(video_meta_h video) +{ + int ret; + 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); + 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; + +} + +#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 ret; + video_meta_s* _src; + video_meta_s* _dst; + + if((src != NULL)) + { + _src = (video_meta_s*)src; + _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); + 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(_src->album != NULL) + { + _dst->album = (char*)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); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(_src->artist != NULL) + { + _dst->artist = (char*)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); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(_src->title != NULL) + { + _dst->title = (char*)strdup(_src->title); + if(_dst->title == NULL) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + video_meta_destroy((video_meta_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + if(_src->description != NULL) + { + _dst->description = (char*)strdup(_src->description); + if(_dst->description == NULL) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + video_meta_destroy((video_meta_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + 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_meta_destroy((video_meta_h)_dst); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + } + *dst =(video_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 video_meta_get_longitude(video_meta_h video, double* longitude) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && longitude) + { + *longitude = _video->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; + } + + return ret; +} +int video_meta_get_latitude(video_meta_h video, double* latitude) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && latitude) + { + *latitude = _video->latitude; + 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_meta_get_album(video_meta_h video, char** album) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video) + { + if((_video->album != NULL) && (strlen(_video->album) > 0)) + { + char* new_string = strdup(_video->album); + if(NULL == new_string) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *album = new_string; + } + else + { + *album = 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 video_meta_get_artist(video_meta_h video, char** artist) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video) + { + if((_video->artist != NULL) && (strlen(_video->artist) > 0)) + { + char* new_string = strdup(_video->artist); + if(NULL == new_string) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *artist = new_string; + } + else + { + *artist = 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 video_meta_get_title(video_meta_h video, char** title) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video) + { + if((_video->title != NULL) && (strlen(_video->title) > 0)) + { + char* new_string = strdup(_video->title); + if(NULL == new_string) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, 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); + ret = MEDIA_CONTENT_ERROR_INVALID_PARAMETER; + } + + return ret; + +} +int video_meta_get_description(video_meta_h video, char** description) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video) + { + if((_video->description != NULL) && (strlen(_video->description) > 0)) + { + char* new_string = strdup(_video->description); + if(NULL == new_string) + { + LOGE("[%s]OUT_OF_MEMORY(0x%08x)", __FUNCTION__, MEDIA_CONTENT_ERROR_OUT_OF_MEMORY); + return MEDIA_CONTENT_ERROR_OUT_OF_MEMORY; + } + *description = new_string; + } + 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 video_meta_get_time_played(video_meta_h video, int* time_played) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video) + { + *time_played = _video->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 video_meta_get_duration(video_meta_h video, int* duration) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && duration) + { + *duration = _video->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 video_meta_get_width(video_meta_h video, int* width) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && width) + { + *width = _video->width; + 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_meta_get_height(video_meta_h video, int* height) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && height) + { + *height = _video->height; + 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_meta_get_orientation(video_meta_h video, media_content_orientation_e* orientation) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && orientation) + { + *orientation = _video->orientation; + 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_meta_get_date_taken(video_meta_h video, time_t* date_taken) +{ + int ret; + video_meta_s* _video = (video_meta_s*)video; + if(_video && date_taken) + { + *date_taken = _video->date_taken; + 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_meta_update_time_played_to_db(video_meta_h video, int time_played) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + video_meta_s* _video = (video_meta_s*)video; + + if(_video != NULL ) + { + ret = minfo_update_video_meta_info_int(_video->video_id,MINFO_VIDEO_META_BOOKMARK_LAST_PLAYED,time_played); + 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 video_bookmark_foreach_bookmark_from_db(video_meta_h video,video_bookmark_filter_h filter, video_bookmark_cb callback,void* user_data) +{ + 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) + { + 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(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); + } + + 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; + + + while( sqlite3_step(stmt) == SQLITE_ROW) + { + 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); + } + if(stmt != NULL) + { + sqlite3_finalize(stmt); + } + + return ret; + + + +} + + +int video_bookmark_destroy(video_bookmark_h bookmark) +{ + 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); + 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_clone(video_bookmark_h* dst, video_bookmark_h src) +{ + 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; + } + } + + ret = MEDIA_CONTENT_ERROR_NONE; + *dst = (video_bookmark_h)_dst; + } + else + { + LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, 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 ret; + video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; + if(_bookmark ) + { + *time_marked = _bookmark->time_marked; + 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_get_thumbnail_path(video_bookmark_h bookmark, char** thumbnail) +{ + 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; + + } + else + { + LOGE("[%s]INVALID_PARAMETER(0x%08x)", __FUNCTION__, 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 ret = MEDIA_CONTENT_ERROR_NONE; + + video_meta_s* _video = (video_meta_s*)video; + + if(_video != NULL) + { + ret = minfo_add_bookmark(_video->video_id,time,thumbnail_path); + 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 video_bookmark_delete_from_db(video_bookmark_h bookmark) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + video_bookmark_s* _bookmark = (video_bookmark_s*)bookmark; + + if( _bookmark != NULL) + { + ret = minfo_delete_bookmark(_bookmark->bookmark_id); + 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; + +} + + + diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt new file mode 100755 index 0000000..f2e2846 --- /dev/null +++ b/test/CMakeLists.txt @@ -0,0 +1,18 @@ +SET(fw_test "${fw_name}-test") + +INCLUDE(FindPkgConfig) +pkg_check_modules(${fw_test} REQUIRED glib-2.0) + +FOREACH(flag ${${fw_test}_CFLAGS}) + SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") +ENDFOREACH(flag) + +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") + +aux_source_directory(. sources) +FOREACH(src ${sources}) + GET_FILENAME_COMPONENT(src_name ${src} NAME_WE) + MESSAGE("${src_name}") + ADD_EXECUTABLE(${src_name} ${src}) + TARGET_LINK_LIBRARIES(${src_name} ${fw_name} ${${fw_test}_LDFLAGS}) +ENDFOREACH() diff --git a/test/media-content_test.c b/test/media-content_test.c new file mode 100644 index 0000000..7fc041c --- /dev/null +++ b/test/media-content_test.c @@ -0,0 +1,699 @@ +/*
+* 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;
+
+}
+
+
+
|