From adcab77a15a68cd488c47080e523945ca06e9c3a Mon Sep 17 00:00:00 2001 From: Haejeong Kim Date: Mon, 20 Jul 2015 17:09:40 +0900 Subject: [PATCH] Update document and Code. Support METADATA_ALBUM_ARTIST and METADATA_AUDIO_BITPERSAMPLE Change-Id: Ib532787876aad03a126f283be3caffb695754fc4 --- CMakeLists.txt | 6 +- include/metadata_extractor.h | 232 +++--- include/metadata_extractor_private.h | 38 +- include/metadata_extractor_type.h | 88 +- packaging/capi-media-metadata-extractor.spec | 19 +- src/metadata_extractor.c | 926 +++++++++------------ test/CMakeLists.txt | 2 +- ..._extractor_test.c => metadata_extractor_test.c} | 173 ++-- 8 files changed, 730 insertions(+), 754 deletions(-) mode change 100644 => 100755 CMakeLists.txt mode change 100644 => 100755 include/metadata_extractor.h mode change 100644 => 100755 include/metadata_extractor_private.h mode change 100644 => 100755 include/metadata_extractor_type.h mode change 100644 => 100755 packaging/capi-media-metadata-extractor.spec mode change 100644 => 100755 src/metadata_extractor.c mode change 100644 => 100755 test/CMakeLists.txt rename test/{multimeida_metadata_extractor_test.c => metadata_extractor_test.c} (68%) mode change 100644 => 100755 diff --git a/CMakeLists.txt b/CMakeLists.txt old mode 100644 new mode 100755 index bf567a0..d9bfd3f --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,7 +18,7 @@ SET(Services SET(project_prefix "capi") SET(prefix "/usr") SET(version "0.0.1") -SET(maintainer "Seungkeun Lee , Kangho Hur") +SET(maintainer "Haejeong Kim ") SET(description "A Metadata Extractor library in Tizen Native API") SET(service "media") SET(submodule "metadata-extractor") @@ -43,7 +43,7 @@ FOREACH(flag ${${fw_name}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -fPIC -Wall -Werror") SET(CMAKE_C_FLAGS_DEBUG "-O0 -g") IF("${ARCH}" MATCHES "^arm.*") @@ -51,7 +51,7 @@ IF("${ARCH}" MATCHES "^arm.*") ENDIF("${ARCH}" MATCHES "^arm.*") ADD_DEFINITIONS("-DPREFIX=\"${CMAKE_INSTALL_PREFIX}\"") -ADD_DEFINITIONS("-DTIZEN_DEBUG") +ADD_DEFINITIONS("-D_FILE_OFFSET_BITS=64") SET(CMAKE_EXE_LINKER_FLAGS "-Wl,--as-needed -Wl,--rpath=${LIB_INSTALL_DIR}") diff --git a/include/metadata_extractor.h b/include/metadata_extractor.h old mode 100644 new mode 100755 index e399ab5..b238fa4 --- a/include/metadata_extractor.h +++ b/include/metadata_extractor.h @@ -27,172 +27,206 @@ extern "C" { #endif /* __cplusplus */ /** - * @addtogroup CAPI_METADATA_EXTRACTOR_MODULE - * @{ - * * @file metadata_extractor.h - * @brief This file contains the multimedia content metadata extractor API and related structure and enumeration. \n - * Description of metadata: duration, bitrate, album, artist, author, genre and description etc. \n + * @brief This file contains the multimedia content metadata extractor API and related structure and enumeration. + * It also contains the description of metadata: duration, bitrate, album, artist, author, genre, description, and so on. */ +/** + * @addtogroup CAPI_METADATA_EXTRACTOR_MODULE + * @{ + */ /** - * @brief Create metadata - * - * @remarks @a metadata must be released metadata_extractor_destroy() by you + * @brief Creates metadata. + * @since_tizen 2.3 + * @remarks You must release @a metadata using metadata_extractor_destroy(). * - * @param [in] metadata The handle to metadata - * @return 0 on success, otherwise a negative error value + * @param[in] metadata The handle to metadata + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY Not enough memory is available + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied * @see metadata_extractor_destroy() */ int metadata_extractor_create(metadata_extractor_h *metadata); - /** - * @brief Set file path to extract - * + * @brief Sets the file path to extract. + * @since_tizen 2.3 * @param [in] metadata The handle to metadata - * @param [in] path path to extract metadata - * @return 0 on success, otherwise a negative error value + * @param [in] path The path to extract metadata + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #METADATA_EXTRACTOR_ERROR_FILE_EXISTS File not exist - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Create metadata handle by calling metadata_extractor_create() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_FILE_EXISTS File does not exist + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Create a metadata handle by calling metadata_extractor_create(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ int metadata_extractor_set_path(metadata_extractor_h metadata, const char *path); /** - * @brief Set buffer to extract - * + * @brief Sets the buffer to extract. + * @since_tizen 2.3 * @param [in] metadata The handle to metadata - * @param [in] buffer buffer to extract metadata - * @param [in] size buffer size - * @return 0 on success, otherwise a negative error value + * @param [in] buffer The buffer to extract metadata + * @param [in] size The buffer size + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Create metadata handle by calling metadata_extractor_create() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Create a metadata handle by calling metadata_extractor_create(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ - int metadata_extractor_set_buffer(metadata_extractor_h metadata, const void *buffer, int size); /** - * @brief Destroy metadata - * + * @brief Destroys metadata. + * @since_tizen 2.3 * @param [in] metadata The handle to metadata - * @return 0 on success, otherwise a negative error value + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Create metadata handle by calling metadata_extractor_create() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Create a metadata handle by calling metadata_extractor_create(). * @see metadata_extractor_create() */ int metadata_extractor_destroy(metadata_extractor_h metadata); - /** - * @brief Get metadata - * - * @remarks @a value must be released with @c free() by you - * - * @param [in] metadata The handle to metadata - * @param [in] attribute key attribute name to get - * @param [out] value The value of the attribute - * @return 0 on success, otherwise a negative error value + * @brief Gets metadata. + * @since_tizen 2.3 + * + * @remarks You must release @a value using @c free(). \n + * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n + * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * + * @param[in] metadata The handle to metadata + * @param[in] attribute The key attribute name to get + * @param[out] value The value of the attribute + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY Not enough memory is available - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Set path to extract by calling metadata_extractor_set_path() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Set the path to extract by calling metadata_extractor_set_path(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ int metadata_extractor_get_metadata(metadata_extractor_h metadata, metadata_extractor_attr_e attribute, char **value); - /** - * @brief Get artwork image in media file - * - * @remarks @a artwork and @a artwork_mime must be released with @c free() by you - * - * @param [in] metadata The handle to metadata - * @param [out] artwork encoded artwork image - * @param [out] size encoded artwork size - * @param [out] mime_type mime type of artwork - * @return 0 on success, otherwise a negative error value + * @brief Gets the artwork image in a media file. + * @since_tizen 2.3 + * + * @remarks You must release @a artwork and @a artwork_mime using @c free(). \n + * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n + * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * + * @param[in] metadata The handle to metadata + * @param[out] artwork The encoded artwork image + * @param[out] size The encoded artwork size + * @param[out] mime_type The mime type of artwork + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY Not enough memory is available - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Set path to extract by calling metadata_extractor_set_path() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Set the path to extract by calling metadata_extractor_set_path(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ int metadata_extractor_get_artwork(metadata_extractor_h metadata, void **artwork, int *size, char **mime_type); - /** - * @brief Get frame of video media file - * - * @remarks @a frame must be released with @c free() by you - * - * @param [in] metadata The handle to metadata - * @param [out] frame raw frame data in RGB888 - * @param [out] size The frame data size - * @return 0 on success, otherwise a negative error value + * @brief Gets the frame of a video media file. + * @since_tizen 2.3 + * + * @remarks You must release @a frame using @c free(). + * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n + * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * + * @param[in] metadata The handle to metadata + * @param[out] frame The raw frame data in RGB888 + * @param[out] size The frame data size + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY Not enough memory is available - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Set path to extract by calling metadata_extractor_set_path() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Set the path to extract by calling metadata_extractor_set_path(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ int metadata_extractor_get_frame(metadata_extractor_h metadata, void **frame, int *size); - /** - * @brief Get synclyric of media file - * - * @remarks @a lyrics must be released with @c free() by you - * - * @param [in] metadata The handle to metadata - * @param [in] index Index of time/lyrics set - * @param [out] time_info Time information of index - * @param [out] lyrics Lyric of index - * @return 0 on success, otherwise a negative error value + * @brief Gets the synclyrics of a media file. + * @since_tizen 2.3 + * + * @remarks You must release @a lyrics using @c free(). + * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n + * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * + * @param[in] metadata The handle to metadata + * @param[in] index The index of time/lyrics to set + * @param[out] time_stamp The time information of the index + * @param[out] lyrics The lyrics of the index + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Set path to extract by calling metadata_extractor_set_path() - * @pre Get time/lyrics set number by calling metadata_extractor_get_metadata(METADATA_SYNCLYRICS_NUM) - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Set the path to extract by calling metadata_extractor_set_path(). + * @pre Get the time/lyrics set number by calling metadata_extractor_get_metadata(METADATA_SYNCLYRICS_NUM). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ int metadata_extractor_get_synclyrics(metadata_extractor_h metadata, int index, unsigned long *time_stamp, char **lyrics); /** - * @brief Get a frame of video media - * - * @remarks @a frame must be released with @c free() by you - * - * @param [in] metadata The handle to metadata - * @param [in] timestamp The timestamp in milliseconds - * @param [in] is_accurate @a true, user can get an accurated frame for given the timestamp.\n - * @a false, user can only get the nearest i-frame of video rapidly. - * @param [out] frame raw frame data in RGB888 - * @param [out] size The frame data size - * @return 0 on success, otherwise a negative error value + * @brief Gets the frame of a video media. + * @since_tizen 2.3 + * + * @remarks You must release @a frame using @c free(). + * In case of accessing specific path in internal storage or external storage, you may add the privilege for accessing the path. \n + * For example, if you get the specific path by using storage_get_directory(). you should add previlege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * + * @param[in] metadata The handle to metadata + * @param[in] timestamp The timestamp in milliseconds + * @param[in] is_accurate If @c true the user can get an accurate frame for the given timestamp,\n + * otherwise @c false if the user can only get the nearest i-frame of the video rapidly + * @param[out] frame The raw frame data in RGB888 + * @param[out] size The frame data size + * @return @c 0 on success, + * otherwise a negative error value * @retval #METADATA_EXTRACTOR_ERROR_NONE Successful * @retval #METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY Not enough memory is available - * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal Operation Fail - * @pre Set path to extract by calling metadata_extractor_set_path() - * @see metadata_extractor_create(), metadata_extractor_destroy() + * @retval #METADATA_EXTRACTOR_ERROR_OPERATION_FAILED Internal operation failed + * @retval #METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED Permission denied + * @pre Set the path to extract by calling metadata_extractor_set_path(). + * @see metadata_extractor_create() + * @see metadata_extractor_destroy() */ - int metadata_extractor_get_frame_at_time(metadata_extractor_h metadata, unsigned long timestamp, bool is_accurate, void **frame, int *size); /** diff --git a/include/metadata_extractor_private.h b/include/metadata_extractor_private.h old mode 100644 new mode 100755 index 7847ea5..3c83f78 --- a/include/metadata_extractor_private.h +++ b/include/metadata_extractor_private.h @@ -20,17 +20,44 @@ #include #include - +#include #ifdef __cplusplus extern "C" { #endif /* __cplusplus */ +#ifdef LOG_TAG +#undef LOG_TAG +#endif +#define LOG_TAG "CAPI_MEDIA_METADATA_EXTRACTOR" + +#define metadata_extractor_debug(fmt, arg...) do { \ + LOGD(""fmt"", ##arg); \ + } while (0) + +#define metadata_extractor_info(fmt, arg...) do { \ + LOGI(""fmt"", ##arg); \ + } while (0) + +#define metadata_extractor_error(fmt, arg...) do { \ + LOGE(""fmt"", ##arg); \ + } while (0) -typedef struct -{ +#define metadata_extractor_debug_fenter() do { \ + LOGD(""); \ + } while (0) + +#define metadata_extractor_debug_fleave() do { \ + LOGD(""); \ + } while (0) + +#define metadata_extractor_sucure_info(fmt, arg...) do { \ + SECURE_LOGI(""fmt"", ##arg); \ + } while (0) + +typedef struct { char *path; - char *buffer; + void *buffer; int buffer_size; bool extract_meta; @@ -39,8 +66,7 @@ typedef struct MMHandleType attr_h; MMHandleType tag_h; -}metadata_extractor_s; - +} metadata_extractor_s; #ifdef __cplusplus } diff --git a/include/metadata_extractor_type.h b/include/metadata_extractor_type.h old mode 100644 new mode 100755 index fda4013..b5cd266 --- a/include/metadata_extractor_type.h +++ b/include/metadata_extractor_type.h @@ -14,8 +14,6 @@ * limitations under the License. */ - - #ifndef __TIZEN_MEDIA_METADATA_EXTRACTOR_TYPE_H__ #define __TIZEN_MEDIA_METADATA_EXTRACTOR_TYPE_H__ @@ -25,73 +23,78 @@ extern "C" { #endif /* __cplusplus */ +/** + * @file metadata_extractor_type.h + */ /** * @addtogroup CAPI_METADATA_EXTRACTOR_MODULE * @{ */ -/** Content Error Class */ -#define METADATA_EXTRACTOR_ERROR_CLASS TIZEN_ERROR_MULTIMEDIA_CLASS | 0x80 +/** @brief Definition for Content Error Class */ +#define METADATA_EXTRACTOR_ERROR_CLASS TIZEN_ERROR_METADATA_EXTRACTOR /** * @ingroup CAPI_METADATA_EXTRACTOR_MODULE - * @brief The enumerations of metadata extractor error + * @brief Enumeration for metadata extractor error. */ typedef enum { - METADATA_EXTRACTOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ - METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ - METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ - METADATA_EXTRACTOR_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File not exist */ - METADATA_EXTRACTOR_ERROR_OPERATION_FAILED = METADATA_EXTRACTOR_ERROR_CLASS |0x01, /**< Invalid internal operation */ -} metadata_extractor_error_e; + METADATA_EXTRACTOR_ERROR_NONE = TIZEN_ERROR_NONE, /**< Successful */ + METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER = TIZEN_ERROR_INVALID_PARAMETER, /**< Invalid parameter */ + METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY = TIZEN_ERROR_OUT_OF_MEMORY, /**< Out of memory */ + METADATA_EXTRACTOR_ERROR_FILE_EXISTS = TIZEN_ERROR_FILE_EXISTS, /**< File does not exist */ + METADATA_EXTRACTOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ + METADATA_EXTRACTOR_ERROR_OPERATION_FAILED = METADATA_EXTRACTOR_ERROR_CLASS | 0x01, /**< Invalid internal operation */ +} + metadata_extractor_error_e; /** * @ingroup CAPI_METADATA_EXTRACTOR_MODULE - * @brief The enumerations of attribute + * @brief Enumeration for attribute. */ -typedef enum -{ +typedef enum { METADATA_DURATION = 0, /**< Duration */ METADATA_VIDEO_BITRATE, /**< Video Bitrate */ METADATA_VIDEO_FPS, /**< Video FPS */ - METADATA_VIDEO_WIDTH, /**< Video Width*/ - METADATA_VIDEO_HEIGHT, /**< Video Height*/ + METADATA_VIDEO_WIDTH, /**< Video Width */ + METADATA_VIDEO_HEIGHT, /**< Video Height */ METADATA_HAS_VIDEO, /**< Video stream count */ - METADATA_AUDIO_BITRATE, /**< Audio Bitrate*/ - METADATA_AUDIO_CHANNELS, /**< Audio Channels*/ - METADATA_AUDIO_SAMPLERATE, /**< Audio Samplerate*/ + METADATA_AUDIO_BITRATE, /**< Audio Bitrate */ + METADATA_AUDIO_CHANNELS, /**< Audio Channels */ + METADATA_AUDIO_SAMPLERATE, /**< Audio Samplerate */ + METADATA_AUDIO_BITPERSAMPLE, /**< Audio bit per sample */ METADATA_HAS_AUDIO, /**< Audio stream count */ - METADATA_ARTIST, /**< Artist*/ - METADATA_TITLE, /**< Title*/ - METADATA_ALBUM, /**< Album*/ - METADATA_GENRE, /**< Genre*/ - METADATA_AUTHOR, /**< Author*/ - METADATA_COPYRIGHT, /**< Copyright*/ - METADATA_DATE, /**< Date*/ - METADATA_DESCRIPTION, /**< Description*/ - METADATA_COMMENT, /**< Comment*/ - METADATA_TRACK_NUM, /**< Track number info*/ - METADATA_CLASSIFICATION, /**< Classification*/ - METADATA_RATING, /**< Rating*/ - METADATA_LONGITUDE, /**< Longitude*/ - METADATA_LATITUDE, /**< Latitude*/ - METADATA_ALTITUDE, /**< Altitude*/ - METADATA_CONDUCTOR, /**< Conductor*/ - METADATA_UNSYNCLYRICS, /**< Unsyncronized lyric*/ - METADATA_SYNCLYRICS_NUM, /**< Syncronized lyric (time/lyric set) number*/ - METADATA_RECDATE, /**< Recording date*/ - METADATA_ROTATE, /**< Rotate(Orientation) Information*/ + METADATA_ARTIST, /**< Artist */ + METADATA_TITLE, /**< Title */ + METADATA_ALBUM, /**< Album */ + METADATA_ALBUM_ARTIST, /**< Album_Artist */ + METADATA_GENRE, /**< Genre */ + METADATA_AUTHOR, /**< Author */ + METADATA_COPYRIGHT, /**< Copyright */ + METADATA_DATE, /**< Date */ + METADATA_DESCRIPTION, /**< Description */ + METADATA_COMMENT, /**< Comment */ + METADATA_TRACK_NUM, /**< Track number info */ + METADATA_CLASSIFICATION, /**< Classification */ + METADATA_RATING, /**< Rating */ + METADATA_LONGITUDE, /**< Longitude */ + METADATA_LATITUDE, /**< Latitude */ + METADATA_ALTITUDE, /**< Altitude */ + METADATA_CONDUCTOR, /**< Conductor */ + METADATA_UNSYNCLYRICS, /**< Unsynchronized lyric */ + METADATA_SYNCLYRICS_NUM, /**< Synchronized lyric (time/lyric set) number */ + METADATA_RECDATE, /**< Recording date */ + METADATA_ROTATE, /**< Rotate(Orientation) Information */ } metadata_extractor_attr_e; - /** * @ingroup CAPI_METADATA_EXTRACTOR_MODULE - * @brief The handle of metadata extractor + * @brief The metadata extractor handle. */ -typedef struct metadata_extractor_s* metadata_extractor_h; +typedef struct metadata_extractor_s *metadata_extractor_h; /** * @} @@ -101,5 +104,4 @@ typedef struct metadata_extractor_s* metadata_extractor_h; } #endif /* __cplusplus */ - #endif /*__TIZEN_MEDIA_METADATA_EXTRACTOR_TYPE_H__*/ diff --git a/packaging/capi-media-metadata-extractor.spec b/packaging/capi-media-metadata-extractor.spec old mode 100644 new mode 100755 index 4f2362f..c90c886 --- a/packaging/capi-media-metadata-extractor.spec +++ b/packaging/capi-media-metadata-extractor.spec @@ -1,8 +1,8 @@ Name: capi-media-metadata-extractor Summary: A media metadata extractor library in SLP C API -Version: 0.1.0 -Release: 18 -Group: Multimedia/API +Version: 0.1.1 +Release: 1 +Group: System/Libraries License: Apache-2.0 Source0: %{name}-%{version}.tar.gz Source1001: capi-media-metadata-extractor.manifest @@ -19,7 +19,7 @@ Group: Multimedia/Development Requires: %{name} = %{version}-%{release} %description devel -A media metadata extractor library in SLP C API. +A media metadata extractor library in SLP C API %prep %setup -q @@ -27,14 +27,17 @@ cp %{SOURCE1001} . %build +export CFLAGS+=" -Wextra -Wno-array-bounds" +export CFLAGS+=" -Wno-ignored-qualifiers -Wno-unused-parameter -Wshadow" +export CFLAGS+=" -Wwrite-strings -Wswitch-default" MAJORVER=`echo %{version} | awk 'BEGIN {FS="."}{print $1}'` %cmake . -DFULLVER=%{version} -DMAJORVER=${MAJORVER} make %{?jobs:-j%jobs} %install %make_install - - +mkdir -p %{buildroot}/%{_datadir}/license +cp -rf %{_builddir}/%{name}-%{version}/LICENSE.APLv2.0 %{buildroot}/%{_datadir}/license/%{name} %post -p /sbin/ldconfig %postun -p /sbin/ldconfig @@ -42,11 +45,9 @@ make %{?jobs:-j%jobs} %files %manifest %{name}.manifest -%license LICENSE.APLv2.0 -%manifest capi-media-metadata-extractor.manifest %{_libdir}/libcapi-media-metadata-extractor.so +%{_datadir}/license/%{name} %files devel -%manifest %{name}.manifest %{_includedir}/media/*.h %{_libdir}/pkgconfig/capi-media-metadata-extractor.pc diff --git a/src/metadata_extractor.c b/src/metadata_extractor.c old mode 100644 new mode 100755 index 8fcd16e..6396295 --- a/src/metadata_extractor.c +++ b/src/metadata_extractor.c @@ -19,19 +19,20 @@ #include #include #include -#include #include #include #define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} #define META_MAX_LEN 256 -#ifdef LOG_TAG -#undef LOG_TAG -#endif -#define LOG_TAG "CAPI_MEDIA_METADATA_EXTRACTOR" +typedef enum { + METADATA_TYPE_STREAM = 0, + METADATA_TYPE_ATTR, + METADATA_TYPE_TAG, +} metadata_extractor_type_e; -static int __metadata_extractor_check_and_extract_meta(metadata_extractor_s *metadata); +static int __metadata_extractor_check_and_extract_meta(metadata_extractor_s *metadata, metadata_extractor_type_e metadata_type); +static int __metadata_extractor_get_stream_info(metadata_extractor_s *metadata, const char *path); static int __metadata_extractor_create_content_attrs(metadata_extractor_s *metadata, const char *path); static int __metadata_extractor_create_tag_attr(metadata_extractor_s *metadata, const char *path); static int __metadata_extractor_create_content_attrs_from_buffer(metadata_extractor_s *metadata, const void *buffer, int size); @@ -52,6 +53,7 @@ static int __metadata_extractor_get_video_track_count(metadata_extractor_s *meta static int __metadata_extractor_get_artist(metadata_extractor_s *metadata, char **artist); static int __metadata_extractor_get_title(metadata_extractor_s *metadata, char **title); static int __metadata_extractor_get_album(metadata_extractor_s *metadata, char **album); +static int __metadata_extractor_get_album_artist(metadata_extractor_s *metadata, char **album_artist); static int __metadata_extractor_get_genre(metadata_extractor_s *metadata, char **genre); static int __metadata_extractor_get_author(metadata_extractor_s *metadata, char **author); static int __metadata_extractor_get_copyright(metadata_extractor_s *metadata, char **copyright); @@ -71,89 +73,119 @@ static int __metadata_extractor_get_rotate(metadata_extractor_s *metadata, char static int __metadata_extractor_get_synclyrics_pair_num(metadata_extractor_s *metadata, int *synclyrics_num); static int __metadata_extractor_destroy_handle(metadata_extractor_s *metadata); -static int __metadata_extractor_check_and_extract_meta(metadata_extractor_s *metadata) +static int __metadata_extractor_check_and_extract_meta(metadata_extractor_s *metadata, metadata_extractor_type_e metadata_type) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - LOGI("enter \n"); - - if(metadata->extract_meta) - { - LOGI("metadata already extracted \n"); - return ret; + if ((!metadata) || ((!metadata->path) && (!metadata->buffer))) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->path != NULL) - { - ret = __metadata_extractor_create_content_attrs(metadata, metadata->path); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (metadata_type == METADATA_TYPE_STREAM) { + if ((metadata) && (metadata->attr_h)) { return ret; + } else { + metadata_extractor_debug("Extract Stream Info"); + ret = __metadata_extractor_get_stream_info(metadata, metadata->path); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + return ret; + } } - - ret = __metadata_extractor_create_tag_attr(metadata, metadata->path); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + } else if (metadata_type == METADATA_TYPE_ATTR) { + if ((metadata) && (metadata->attr_h)) { return ret; + } else { + metadata_extractor_debug("Extract Content attrs"); + if (metadata->path != NULL) { + ret = __metadata_extractor_create_content_attrs(metadata, metadata->path); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + return ret; + } + } else if (metadata->buffer != NULL) { + ret = __metadata_extractor_create_content_attrs_from_buffer(metadata, metadata->buffer, metadata->buffer_size); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + return ret; + } + } } - } - else if(metadata->buffer != NULL) - { - ret = __metadata_extractor_create_content_attrs_from_buffer(metadata, metadata->buffer, metadata->buffer_size); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + } else if (metadata_type == METADATA_TYPE_TAG) { + if ((metadata) && (metadata->tag_h)) { return ret; + } else { + metadata_extractor_debug("Extract Tag attrs"); + if (metadata->path != NULL) { + ret = __metadata_extractor_create_tag_attr(metadata, metadata->path); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + return ret; + } + } else if (metadata->buffer != NULL) { + ret = __metadata_extractor_create_tag_attrs_from_buffer(metadata, metadata->buffer, metadata->buffer_size); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + return ret; + } + } } + } else { + metadata_extractor_error("INVALID_PARAMETER(%d)", metadata_type); + return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; + } - ret = __metadata_extractor_create_tag_attrs_from_buffer(metadata, metadata->buffer, metadata->buffer_size); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { - return ret; + return ret; +} + +static int __metadata_extractor_get_stream_info(metadata_extractor_s *metadata, const char *path) +{ + unsigned int ret = METADATA_EXTRACTOR_ERROR_NONE; + int _audio_track_cnt = 0; + int _video_track_cnt = 0; + + ret = mm_file_get_stream_info(path, &_audio_track_cnt, &_video_track_cnt); + + if (ret != MM_ERROR_NONE) { + if (ret == MM_ERROR_FILE_NOT_FOUND) { + metadata_extractor_error("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); + return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; + } else { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); + return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } - metadata->extract_meta = true; - - LOGI("leave \n"); + metadata->audio_track_cnt = _audio_track_cnt; + metadata->video_track_cnt = _video_track_cnt; return ret; } static int __metadata_extractor_create_content_attrs(metadata_extractor_s *metadata, const char *path) { - int ret = METADATA_EXTRACTOR_ERROR_NONE; + unsigned int ret = METADATA_EXTRACTOR_ERROR_NONE; MMHandleType content = 0; char *err_attr_name = NULL; int _audio_track_cnt = 0; int _video_track_cnt = 0; - LOGI("enter \n"); - ret = mm_file_create_content_attrs(&content, path); - if(ret != MM_ERROR_NONE) - { - if(ret == MM_ERROR_FILE_NOT_FOUND) - { - LOGE("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); + if (ret != MM_ERROR_NONE) { + if (ret == MM_ERROR_FILE_NOT_FOUND) { + metadata_extractor_error("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; - } - else - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + } else { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } ret = mm_file_get_attrs(content, &err_attr_name, - MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_cnt, - MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &_audio_track_cnt, - NULL); + MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_cnt, + MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &_audio_track_cnt, + NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); mm_file_destroy_content_attrs(content); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; @@ -163,8 +195,6 @@ static int __metadata_extractor_create_content_attrs(metadata_extractor_s *metad metadata->audio_track_cnt = _audio_track_cnt; metadata->video_track_cnt = _video_track_cnt; - LOGI("leave \n"); - return ret; } @@ -172,68 +202,55 @@ static int __metadata_extractor_create_content_attrs(metadata_extractor_s *metad static int __metadata_extractor_create_tag_attr(metadata_extractor_s *metadata, const char *path) { - int ret = METADATA_EXTRACTOR_ERROR_NONE; + unsigned int ret = METADATA_EXTRACTOR_ERROR_NONE; MMHandleType tag = 0; - LOGI("enter \n"); ret = mm_file_create_tag_attrs(&tag, path); - if(ret != MM_ERROR_NONE) - { - if(ret == MM_ERROR_FILE_NOT_FOUND) - { - LOGE("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); + if (ret != MM_ERROR_NONE) { + if (ret == MM_ERROR_FILE_NOT_FOUND) { + metadata_extractor_error("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; - } - else - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + } else { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } - metadata->tag_h= tag; + metadata->tag_h = tag; - LOGI("leave \n"); return ret; } static int __metadata_extractor_create_content_attrs_from_buffer(metadata_extractor_s *metadata, const void *buffer, int size) { - int ret = METADATA_EXTRACTOR_ERROR_NONE; + unsigned int ret = METADATA_EXTRACTOR_ERROR_NONE; MMHandleType content = 0; char *err_attr_name = NULL; int _audio_track_cnt = 0; int _video_track_cnt = 0; - LOGI("enter \n"); - ret = mm_file_create_content_attrs_from_memory(&content, buffer, size, 0); - if(ret != MM_ERROR_NONE) - { - if(ret == MM_ERROR_FILE_NOT_FOUND) - { - LOGE("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); + if (ret != MM_ERROR_NONE) { + if (ret == MM_ERROR_FILE_NOT_FOUND) { + metadata_extractor_error("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; - } - else - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + } else { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } ret = mm_file_get_attrs(content, &err_attr_name, - MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_cnt, - MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &_audio_track_cnt, - NULL); + MM_FILE_CONTENT_VIDEO_TRACK_COUNT, &_video_track_cnt, + MM_FILE_CONTENT_AUDIO_TRACK_COUNT, &_audio_track_cnt, + NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); mm_file_destroy_content_attrs(content); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; @@ -243,37 +260,29 @@ static int __metadata_extractor_create_content_attrs_from_buffer(metadata_extrac metadata->audio_track_cnt = _audio_track_cnt; metadata->video_track_cnt = _video_track_cnt; - LOGI("leave \n"); - return ret; } static int __metadata_extractor_create_tag_attrs_from_buffer(metadata_extractor_s *metadata, const void *buffer, int size) { - int ret = METADATA_EXTRACTOR_ERROR_NONE; + unsigned int ret = METADATA_EXTRACTOR_ERROR_NONE; MMHandleType tag = 0; - LOGI("enter \n"); ret = mm_file_create_tag_attrs_from_memory(&tag, buffer, size, 0); - if(ret != MM_ERROR_NONE) - { - if(ret == MM_ERROR_FILE_NOT_FOUND) - { - LOGE("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); + if (ret != MM_ERROR_NONE) { + if (ret == MM_ERROR_FILE_NOT_FOUND) { + metadata_extractor_error("FILE_NOT_EXISTS(0x%08x)", METADATA_EXTRACTOR_ERROR_FILE_EXISTS); return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; - } - else - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + } else { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } - metadata->tag_h= tag; + metadata->tag_h = tag; - LOGI("leave \n"); return ret; } @@ -284,16 +293,14 @@ static int __metadata_extractor_get_duration(metadata_extractor_s *metadata, int char *err_attr_name = NULL; int _duration = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_DURATION, &_duration, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -309,18 +316,15 @@ static int __metadata_extractor_get_audio_bitrate(metadata_extractor_s *metadata char *err_attr_name = NULL; int _audio_bitrate = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->audio_track_cnt > 0) - { + if (metadata->audio_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITRATE, &_audio_bitrate, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -337,18 +341,15 @@ static int __metadata_extractor_get_audio_channel(metadata_extractor_s *metadata char *err_attr_name = NULL; int _audio_channel = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->audio_track_cnt > 0) - { + if (metadata->audio_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_AUDIO_CHANNELS, &_audio_channel, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -365,18 +366,15 @@ static int __metadata_extractor_get_audio_samplerate(metadata_extractor_s *metad char *err_attr_name = NULL; int _audio_samplerate = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->audio_track_cnt > 0) - { + if (metadata->audio_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_AUDIO_SAMPLERATE, &_audio_samplerate, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -387,13 +385,37 @@ static int __metadata_extractor_get_audio_samplerate(metadata_extractor_s *metad return ret; } +static int __metadata_extractor_get_audio_bitpersample(metadata_extractor_s *metadata, int *bitpersample) +{ + int ret = METADATA_EXTRACTOR_ERROR_NONE; + char *err_attr_name = NULL; + int _audio_bit_per_sample = 0; + + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; + } + + if (metadata->audio_track_cnt > 0) { + ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_AUDIO_BITPERSAMPLE, &_audio_bit_per_sample, NULL); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); + SAFE_FREE(err_attr_name); + return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; + } + } + + *bitpersample = _audio_bit_per_sample; + + return ret; +} + static int __metadata_extractor_get_audio_track_count(metadata_extractor_s *metadata, int *track_cnt) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - if(!metadata) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if (!metadata) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } @@ -408,18 +430,15 @@ static int __metadata_extractor_get_video_bitrate(metadata_extractor_s *metadata char *err_attr_name = NULL; int _video_bitrate = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->video_track_cnt > 0) - { + if (metadata->video_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_VIDEO_BITRATE, &_video_bitrate, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -435,18 +454,15 @@ static int __metadata_extractor_get_video_FPS(metadata_extractor_s *metadata, in char *err_attr_name = NULL; int _video_fps = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->video_track_cnt > 0) - { + if (metadata->video_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_VIDEO_FPS, &_video_fps, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -463,18 +479,15 @@ static int __metadata_extractor_get_video_width(metadata_extractor_s *metadata, char *err_attr_name = NULL; int _video_width = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->video_track_cnt > 0) - { + if (metadata->video_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_VIDEO_WIDTH, &_video_width, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -491,18 +504,15 @@ static int __metadata_extractor_get_video_height(metadata_extractor_s *metadata, char *err_attr_name = NULL; int _video_height = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->video_track_cnt > 0) - { + if (metadata->video_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_VIDEO_HEIGHT, &_video_height, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -520,18 +530,15 @@ static int __metadata_extractor_get_video_thumbnail(metadata_extractor_s *metada void *_video_thumbnail = NULL; int _video_thumbnail_len = 0; - if((!metadata) ||(!metadata->attr_h)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!metadata) || (!metadata->attr_h)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if(metadata->video_track_cnt > 0) - { + if (metadata->video_track_cnt > 0) { ret = mm_file_get_attrs(metadata->attr_h, &err_attr_name, MM_FILE_CONTENT_VIDEO_THUMBNAIL, &_video_thumbnail, &_video_thumbnail_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -547,9 +554,8 @@ static int __metadata_extractor_get_video_track_count(metadata_extractor_s *meta { int ret = METADATA_EXTRACTOR_ERROR_NONE; - if(!metadata) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if (!metadata) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } @@ -566,9 +572,8 @@ static int __metadata_extractor_get_artist(metadata_extractor_s *metadata, char int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ARTIST, &_artist, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -586,9 +591,8 @@ static int __metadata_extractor_get_title(metadata_extractor_s *metadata, char * int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_TITLE, &_title, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -606,9 +610,8 @@ static int __metadata_extractor_get_album(metadata_extractor_s *metadata, char * int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ALBUM, &_album, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -618,6 +621,25 @@ static int __metadata_extractor_get_album(metadata_extractor_s *metadata, char * return ret; } +static int __metadata_extractor_get_album_artist(metadata_extractor_s *metadata, char **album_artist) +{ + int ret = METADATA_EXTRACTOR_ERROR_NONE; + char *err_attr_name = NULL; + char *_album_artist = NULL; + int _tag_len = 0; + + ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ALBUM_ARTIST, &_album_artist, &_tag_len, NULL); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); + SAFE_FREE(err_attr_name); + return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; + } + + *album_artist = _album_artist; + + return ret; +} + static int __metadata_extractor_get_genre(metadata_extractor_s *metadata, char **genre) { int ret = METADATA_EXTRACTOR_ERROR_NONE; @@ -626,9 +648,8 @@ static int __metadata_extractor_get_genre(metadata_extractor_s *metadata, char * int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_GENRE, &_genre, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -646,9 +667,8 @@ static int __metadata_extractor_get_author(metadata_extractor_s *metadata, char int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_AUTHOR, &_author, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -666,9 +686,8 @@ static int __metadata_extractor_get_copyright(metadata_extractor_s *metadata, ch int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_COPYRIGHT, &_copyright, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -686,9 +705,8 @@ static int __metadata_extractor_get_date(metadata_extractor_s *metadata, char ** int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_DATE, &_date, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -706,9 +724,8 @@ static int __metadata_extractor_get_description(metadata_extractor_s *metadata, int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_DESCRIPTION, &_description, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -726,9 +743,8 @@ static int __metadata_extractor_get_comment(metadata_extractor_s *metadata, char int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_COMMENT, &_comment, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -747,19 +763,16 @@ static int __metadata_extractor_get_artwork(metadata_extractor_s *metadata, void int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ARTWORK_SIZE, &_artwork_size, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } - if(_artwork_size > 0) - { + if (_artwork_size > 0) { ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ARTWORK, &_artwork, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -779,9 +792,8 @@ static int __metadata_extractor_get_artwork_mime(metadata_extractor_s *metadata, int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ARTWORK_MIME, &_artwork_mime, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -800,9 +812,8 @@ static int __metadata_extractor_get_track_num(metadata_extractor_s *metadata, ch int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_TRACK_NUM, &_track_num, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -820,9 +831,8 @@ static int __metadata_extractor_get_classification(metadata_extractor_s *metadat int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_CLASSIFICATION, &_classification, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -840,9 +850,8 @@ static int __metadata_extractor_get_rating(metadata_extractor_s *metadata, char int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_RATING, &_rating, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -859,9 +868,8 @@ static int __metadata_extractor_get_longitude(metadata_extractor_s *metadata, do double _longitude = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_LONGITUDE, &_longitude, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -878,9 +886,8 @@ static int __metadata_extractor_get_latitude(metadata_extractor_s *metadata, dou double _latitude = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_LATIDUE, &_latitude, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -897,9 +904,8 @@ static int __metadata_extractor_get_altitude(metadata_extractor_s *metadata, dou double _altitude = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ALTIDUE, &_altitude, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -917,9 +923,8 @@ static int __metadata_extractor_get_conductor(metadata_extractor_s *metadata, ch int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_CONDUCTOR, &_conductor, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -936,9 +941,8 @@ static int __metadata_extractor_get_unsynclyrics(metadata_extractor_s *metadata, int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_UNSYNCLYRICS, &_unsynclyrics, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -956,9 +960,8 @@ static int __metadata_extractor_get_recording_date(metadata_extractor_s *metadat int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_RECDATE, &_rec_date, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -976,9 +979,8 @@ static int __metadata_extractor_get_rotate(metadata_extractor_s *metadata, char int _tag_len = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_ROTATE, &_rotate, &_tag_len, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -995,9 +997,8 @@ static int __metadata_extractor_get_synclyrics_pair_num(metadata_extractor_s *me int _synclyrics_num = 0; ret = mm_file_get_attrs(metadata->tag_h, &err_attr_name, MM_FILE_TAG_SYNCLYRICS_NUM, &_synclyrics_num, NULL); - if(ret != MM_ERROR_NONE) - { - LOGE("err_attr_name(%s), ERROR_UNKNOWN(0x%08x)", err_attr_name, METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); SAFE_FREE(err_attr_name); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } @@ -1011,30 +1012,22 @@ static int __metadata_extractor_destroy_handle(metadata_extractor_s *metadata) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - LOGI("enter \n"); - - if(metadata->attr_h) - { + if (metadata->attr_h) { ret = mm_file_destroy_content_attrs(metadata->attr_h); - if(ret != MM_ERROR_NONE) - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } - if(metadata->tag_h) - { + if (metadata->tag_h) { ret = mm_file_destroy_tag_attrs(metadata->tag_h); - if(ret != MM_ERROR_NONE) - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } } - LOGI("leave \n"); - return ret; } @@ -1043,111 +1036,92 @@ int metadata_extractor_create(metadata_extractor_h *metadata) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - LOGI("enter \n"); - - if(metadata == NULL) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if (metadata == NULL) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - metadata_extractor_s *_metadata = (metadata_extractor_s*)calloc(1,sizeof(metadata_extractor_s)); - if(_metadata == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + metadata_extractor_s *_metadata = (metadata_extractor_s *)calloc(1, sizeof(metadata_extractor_s)); + if (_metadata == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } _metadata->path = NULL; _metadata->buffer = NULL; _metadata->buffer_size = 0; - _metadata->extract_meta = false; _metadata->audio_track_cnt = 0; _metadata->video_track_cnt = 0; *metadata = (metadata_extractor_h)_metadata; - LOGI("leave \n"); - return ret; } int metadata_extractor_set_path(metadata_extractor_h metadata, const char *path) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; - LOGI("enter \n"); - - if((_metadata == NULL) || (path == NULL)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((_metadata == NULL) || (path == NULL)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - LOGI("path [%s] \n", path); + /*check file path.. */ + if (g_file_test(path, G_FILE_TEST_IS_REGULAR)) { + metadata_extractor_sucure_info("path[%s] is exists.", path); + } else { + metadata_extractor_sucure_info("path[%s] is not exists.", path); + return METADATA_EXTRACTOR_ERROR_FILE_EXISTS; + } - if((_metadata->path != NULL) || (_metadata->buffer != NULL)) - { + if ((_metadata->path != NULL) || (_metadata->buffer != NULL)) { __metadata_extractor_destroy_handle(_metadata); SAFE_FREE(_metadata->path); - _metadata->extract_meta = false; _metadata->attr_h = 0; _metadata->tag_h = 0; } _metadata->path = strdup(path); - if(_metadata->path == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + if (_metadata->path == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } - LOGI("leave \n"); - return ret; } int metadata_extractor_set_buffer(metadata_extractor_h metadata, const void *buffer, int size) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; - - LOGI("enter \n"); + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; - if((_metadata == NULL) || (buffer == NULL) || (size <= 0)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((_metadata == NULL) || (buffer == NULL) || (size <= 0)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - if((_metadata->path != NULL) || (_metadata->buffer != NULL)) - { + if ((_metadata->path != NULL) || (_metadata->buffer != NULL)) { __metadata_extractor_destroy_handle(_metadata); SAFE_FREE(_metadata->path); - _metadata->extract_meta = false; _metadata->attr_h = 0; _metadata->tag_h = 0; } - _metadata->buffer = buffer; + _metadata->buffer = (void *)buffer; _metadata->buffer_size = size; - LOGI("leave \n"); - return ret; } int metadata_extractor_destroy(metadata_extractor_h metadata) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; - - LOGI("enter \n"); + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; - if(!_metadata) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if (!_metadata) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } @@ -1157,63 +1131,50 @@ int metadata_extractor_destroy(metadata_extractor_h metadata) SAFE_FREE(_metadata); - LOGI("leave \n"); - return ret; } int metadata_extractor_get_synclyrics(metadata_extractor_h metadata, int index, unsigned long *time_stamp, char **lyrics) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; unsigned long _time_info = 0; char *_lyrics = NULL; int _synclyrics_num = 0; - if((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - ret = __metadata_extractor_check_and_extract_meta(_metadata); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_TAG); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } ret = __metadata_extractor_get_synclyrics_pair_num(_metadata, &_synclyrics_num); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } - if((_synclyrics_num > 0) && (index < _synclyrics_num)) - { + if ((_synclyrics_num > 0) && (index < _synclyrics_num)) { ret = mm_file_get_synclyrics_info((MMHandleType)_metadata->tag_h, index, &_time_info, &_lyrics); - if(ret != MM_ERROR_NONE) - { - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + if (ret != MM_ERROR_NONE) { + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } - if((_lyrics != NULL) && (strlen(_lyrics) > 0)) - { + if ((_lyrics != NULL) && (strlen(_lyrics) > 0)) { *lyrics = strdup(_lyrics); - if(*lyrics == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + if (*lyrics == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } - } - else - { + } else { *lyrics = NULL; } *time_stamp = _time_info; - } - else - { + } else { *lyrics = NULL; *time_stamp = 0; } @@ -1224,252 +1185,230 @@ int metadata_extractor_get_synclyrics(metadata_extractor_h metadata, int index, int metadata_extractor_get_metadata(metadata_extractor_h metadata, metadata_extractor_attr_e attribute, char **value) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; int i_value = 0; double d_value = 0; char *s_value = NULL; int is_string = 0; int is_double = 0; - if((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - ret = __metadata_extractor_check_and_extract_meta(_metadata); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if ((attribute == METADATA_HAS_VIDEO) || (attribute == METADATA_HAS_AUDIO)) { + if (_metadata->path != NULL) + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_STREAM); + else + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_ATTR); + } else if ((attribute >= METADATA_DURATION) && (attribute < METADATA_HAS_AUDIO)) { + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_ATTR); + } else if ((attribute > METADATA_HAS_AUDIO) && (attribute <= METADATA_ROTATE)) { + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_TAG); + } else { + metadata_extractor_error("INVALID_PARAMETER [%d]", attribute); + ret = METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; + } + + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } + /*metadata_extractor_debug("attribute [%d]", attribute); */ + switch (attribute) { - case METADATA_DURATION: - { + case METADATA_DURATION: { is_string = 0; ret = __metadata_extractor_get_duration(_metadata, &i_value); break; } - case METADATA_VIDEO_BITRATE: - { + case METADATA_VIDEO_BITRATE: { is_string = 0; ret = __metadata_extractor_get_video_bitrate(_metadata, &i_value); break; } - case METADATA_VIDEO_FPS: - { + case METADATA_VIDEO_FPS: { is_string = 0; ret = __metadata_extractor_get_video_FPS(_metadata, &i_value); break; } - case METADATA_VIDEO_WIDTH: - { + case METADATA_VIDEO_WIDTH: { is_string = 0; ret = __metadata_extractor_get_video_width(_metadata, &i_value); break; } - case METADATA_VIDEO_HEIGHT: - { + case METADATA_VIDEO_HEIGHT: { is_string = 0; ret = __metadata_extractor_get_video_height(_metadata, &i_value); break; } - case METADATA_HAS_VIDEO: - { + case METADATA_HAS_VIDEO: { is_string = 0; ret = __metadata_extractor_get_video_track_count(_metadata, &i_value); break; } - case METADATA_AUDIO_BITRATE: - { + case METADATA_AUDIO_BITRATE: { is_string = 0; ret = __metadata_extractor_get_audio_bitrate(_metadata, &i_value); break; } - case METADATA_AUDIO_CHANNELS: - { + case METADATA_AUDIO_CHANNELS: { is_string = 0; ret = __metadata_extractor_get_audio_channel(_metadata, &i_value); break; } - case METADATA_AUDIO_SAMPLERATE: - { + case METADATA_AUDIO_SAMPLERATE: { is_string = 0; ret = __metadata_extractor_get_audio_samplerate(_metadata, &i_value); break; } - case METADATA_HAS_AUDIO: - { + case METADATA_AUDIO_BITPERSAMPLE: { + is_string = 0; + ret = __metadata_extractor_get_audio_bitpersample(_metadata, &i_value); + break; + } + case METADATA_HAS_AUDIO: { is_string = 0; ret = __metadata_extractor_get_audio_track_count(_metadata, &i_value); break; } - case METADATA_ARTIST: - { + case METADATA_ARTIST: { is_string = 1; ret = __metadata_extractor_get_artist(_metadata, &s_value); break; } - case METADATA_TITLE: - { + case METADATA_TITLE: { is_string = 1; ret = __metadata_extractor_get_title(_metadata, &s_value); break; } - case METADATA_ALBUM: - { + case METADATA_ALBUM: { is_string = 1; ret = __metadata_extractor_get_album(_metadata, &s_value); break; } - case METADATA_GENRE: - { + case METADATA_ALBUM_ARTIST: { + is_string = 1; + ret = __metadata_extractor_get_album_artist(_metadata, &s_value); + break; + } + case METADATA_GENRE: { is_string = 1; ret = __metadata_extractor_get_genre(_metadata, &s_value); break; } - case METADATA_AUTHOR: - { + case METADATA_AUTHOR: { is_string = 1; ret = __metadata_extractor_get_author(_metadata, &s_value); break; } - case METADATA_COPYRIGHT: - { + case METADATA_COPYRIGHT: { is_string = 1; ret = __metadata_extractor_get_copyright(_metadata, &s_value); break; } - case METADATA_DATE: - { + case METADATA_DATE: { is_string = 1; ret = __metadata_extractor_get_date(_metadata, &s_value); break; } - case METADATA_DESCRIPTION: - { + case METADATA_DESCRIPTION: { is_string = 1; ret = __metadata_extractor_get_description(_metadata, &s_value); break; } - case METADATA_COMMENT: - { + case METADATA_COMMENT: { is_string = 1; ret = __metadata_extractor_get_comment(_metadata, &s_value); break; } - case METADATA_TRACK_NUM: - { + case METADATA_TRACK_NUM: { is_string = 1; ret = __metadata_extractor_get_track_num(_metadata, &s_value); break; } - case METADATA_CLASSIFICATION: - { + case METADATA_CLASSIFICATION: { is_string = 1; ret = __metadata_extractor_get_classification(_metadata, &s_value); break; } - case METADATA_RATING: - { + case METADATA_RATING: { is_string = 1; ret = __metadata_extractor_get_rating(_metadata, &s_value); break; } - case METADATA_LONGITUDE: - { + case METADATA_LONGITUDE: { is_double = 1; ret = __metadata_extractor_get_longitude(_metadata, &d_value); break; } - case METADATA_LATITUDE: - { + case METADATA_LATITUDE: { is_double = 1; ret = __metadata_extractor_get_latitude(_metadata, &d_value); break; } - case METADATA_ALTITUDE: - { + case METADATA_ALTITUDE: { is_double = 1; ret = __metadata_extractor_get_altitude(_metadata, &d_value); break; } - case METADATA_CONDUCTOR: - { + case METADATA_CONDUCTOR: { is_string = 1; ret = __metadata_extractor_get_conductor(_metadata, &s_value); break; } - case METADATA_UNSYNCLYRICS: - { + case METADATA_UNSYNCLYRICS: { is_string = 1; ret = __metadata_extractor_get_unsynclyrics(_metadata, &s_value); break; } - case METADATA_SYNCLYRICS_NUM: - { + case METADATA_SYNCLYRICS_NUM: { is_string = 0; ret = __metadata_extractor_get_synclyrics_pair_num(_metadata, &i_value); break; } - case METADATA_RECDATE: - { + case METADATA_RECDATE: { is_string = 1; ret = __metadata_extractor_get_recording_date(_metadata, &s_value); break; } - case METADATA_ROTATE: - { + case METADATA_ROTATE: { is_string = 1; ret = __metadata_extractor_get_rotate(_metadata, &s_value); break; } - default: - { - LOGE("INVALID_PARAMETER [%d] (0x%08x)", attribute, METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); - return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; - } + default : + break; } - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { *value = NULL; return ret; } - if(is_string) - { - if((s_value != NULL) && (strlen(s_value) > 0)) - { + if (is_string) { + if ((s_value != NULL) && (strlen(s_value) > 0)) { *value = strdup(s_value); - if(*value == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + if (*value == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } - } - else - { + } else { *value = NULL; } - } - else - { - char metadata[META_MAX_LEN] = {0, }; + } else { + char extracted_metadata[META_MAX_LEN] = {0, }; - if(is_double) - { - snprintf(metadata, sizeof(metadata), "%f", d_value); - } - else - { - snprintf(metadata, sizeof(metadata), "%d", i_value); + if (is_double) { + snprintf(extracted_metadata, sizeof(extracted_metadata), "%f", d_value); + } else { + snprintf(extracted_metadata, sizeof(extracted_metadata), "%d", i_value); } - *value = strdup(metadata); - if(*value == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + *value = strdup(extracted_metadata); + if (*value == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } } @@ -1480,36 +1419,29 @@ int metadata_extractor_get_metadata(metadata_extractor_h metadata, metadata_extr int metadata_extractor_get_artwork(metadata_extractor_h metadata, void **artwork, int *size, char **mime_type) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; void *_artwork = NULL; int _artwork_size = 0; char *_artwork_mime = NULL; - LOGI("enter \n"); - - if((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!_metadata) || ((!_metadata->path) && (!_metadata->buffer))) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - ret = __metadata_extractor_check_and_extract_meta(_metadata); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_TAG); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } ret = __metadata_extractor_get_artwork(_metadata, &_artwork, &_artwork_size); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } - if((_artwork_size > 0) && (_artwork != NULL)) - { + if ((_artwork_size > 0) && (_artwork != NULL)) { ret = __metadata_extractor_get_artwork_mime(_metadata, &_artwork_mime); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { *artwork = NULL; *size = 0; @@ -1517,144 +1449,114 @@ int metadata_extractor_get_artwork(metadata_extractor_h metadata, void **artwork } *artwork = calloc(1, _artwork_size); - memcpy(*artwork, _artwork, _artwork_size); - *size = _artwork_size; + if (*artwork != NULL) { + memcpy(*artwork, _artwork, _artwork_size); + *size = _artwork_size; + } else { + *size = 0; + } - if((_artwork_mime != NULL) && (strlen(_artwork_mime) > 0)) - { + if ((_artwork_mime != NULL) && (strlen(_artwork_mime) > 0)) { *mime_type = strdup(_artwork_mime); - if(*mime_type == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + if (*mime_type == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } - } - else - { + } else { *mime_type = NULL; } - } - else - { + } else { *artwork = NULL; *mime_type = NULL; *size = 0; } - LOGI("leave \n"); - return ret; } int metadata_extractor_get_frame(metadata_extractor_h metadata, void **frame, int *size) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; void *_frame = NULL; int _frame_size = 0; - LOGI("enter \n"); - - if((!_metadata) ||((!_metadata->path) && (!_metadata->buffer)) || (!size)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!_metadata) || ((!_metadata->path) && (!_metadata->buffer)) || (!size)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } - ret = __metadata_extractor_check_and_extract_meta(_metadata); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + ret = __metadata_extractor_check_and_extract_meta(_metadata, METADATA_TYPE_ATTR); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } ret = __metadata_extractor_get_video_thumbnail(_metadata, &_frame, &_frame_size); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { return ret; } - if((_frame_size > 0) && (_frame != NULL)) - { + if ((_frame_size > 0) && (_frame != NULL)) { *frame = calloc(1, _frame_size); - if(*frame == NULL) - { - LOGE("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); + if (*frame == NULL) { + metadata_extractor_error("OUT_OF_MEMORY(0x%08x)", METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY); return METADATA_EXTRACTOR_ERROR_OUT_OF_MEMORY; } memcpy(*frame, _frame, _frame_size); *size = _frame_size; - } - else - { + } else { *frame = NULL; *size = 0; } - LOGI("leave \n"); - return ret; } int metadata_extractor_get_frame_at_time(metadata_extractor_h metadata, unsigned long timestamp, bool is_accurate, void **frame, int *size) { int ret = METADATA_EXTRACTOR_ERROR_NONE; - metadata_extractor_s *_metadata = (metadata_extractor_s*)metadata; + metadata_extractor_s *_metadata = (metadata_extractor_s *)metadata; void *_frame = NULL; int _frame_size = 0; int width = 0; int height = 0; long long micro_timestamp = 0; - LOGI("enter \n"); - - if((!_metadata) ||((!_metadata->path) && (!_metadata->buffer)) ||(!size)) - { - LOGE("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); + if ((!_metadata) || ((!_metadata->path) && (!_metadata->buffer)) || (!size)) { + metadata_extractor_error("INVALID_PARAMETER(0x%08x)", METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER); return METADATA_EXTRACTOR_ERROR_INVALID_PARAMETER; } micro_timestamp = (long long)timestamp * 1000; - LOGE("[%d] [%lld]", timestamp, micro_timestamp); + metadata_extractor_debug("accurate [%d] timestamp[%d] micro_timestamp[%lld]", is_accurate, timestamp, micro_timestamp); - if(_metadata->path) - { + if (_metadata->path) { ret = mm_file_get_video_frame(_metadata->path, micro_timestamp, is_accurate, (unsigned char **)&_frame, &_frame_size, &width, &height); - } - else - { + } else { ret = mm_file_get_video_frame_from_memory(_metadata->buffer, _metadata->buffer_size, micro_timestamp, is_accurate, (unsigned char **)&_frame, &_frame_size, &width, &height); } - if(ret != MM_ERROR_NONE) - { + if (ret != MM_ERROR_NONE) { SAFE_FREE(_frame); - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED(0x%08x)", ret); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } - if(_frame != NULL) - { - if((_frame_size > 0)) - { + if (_frame != NULL) { + if ((_frame_size > 0)) { *frame = _frame; *size = _frame_size; - } - else - { + } else { SAFE_FREE(_frame); - LOGE("ERROR_UNKNOWN(0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); + metadata_extractor_error("METADATA_EXTRACTOR_ERROR_OPERATION_FAILED (0x%08x)", METADATA_EXTRACTOR_ERROR_OPERATION_FAILED); return METADATA_EXTRACTOR_ERROR_OPERATION_FAILED; } - } - else - { + } else { *frame = NULL; *size = 0; } - LOGI("leave \n"); - return ret; } diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt old mode 100644 new mode 100755 index f2e2846..282dd7e --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -7,7 +7,7 @@ FOREACH(flag ${${fw_test}_CFLAGS}) SET(EXTRA_CFLAGS "${EXTRA_CFLAGS} ${flag}") ENDFOREACH(flag) -SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall") +SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${EXTRA_CFLAGS} -Wall -pie -Werror") aux_source_directory(. sources) FOREACH(src ${sources}) diff --git a/test/multimeida_metadata_extractor_test.c b/test/metadata_extractor_test.c old mode 100644 new mode 100755 similarity index 68% rename from test/multimeida_metadata_extractor_test.c rename to test/metadata_extractor_test.c index d29a352..a1c442a --- a/test/multimeida_metadata_extractor_test.c +++ b/test/metadata_extractor_test.c @@ -19,34 +19,33 @@ #include #include #include -#include #include -#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} +#define SAFE_FREE(src) { if(src) {free(src); src = NULL;}} #define READ_FROM_FILE(FILE_PATH, data, size) \ -do{ \ - FILE * fp = fopen (FILE_PATH, "r"); \ - if (fp) { \ - fseek (fp, 0, SEEK_END); \ + do { \ + FILE *fp = fopen(FILE_PATH, "r"); \ + if (fp) { \ + fseek(fp, 0, SEEK_END); \ size = ftell(fp); \ - fseek (fp, 0, SEEK_SET); \ - data = malloc (size); \ - fread (data, size, sizeof(char), fp); \ - fclose (fp); \ - printf("file size = %d\n", size ); \ - } \ -}while(0) - -static int _is_file_exist (const char *filename); + fseek(fp, 0, SEEK_SET); \ + data = malloc(size); \ + fread(data, size, sizeof(char), fp); \ + fclose(fp); \ + printf("file size = %d\n", size); \ + } \ + } while (0) + +static int _is_file_exist(const char *filename); static bool __capi_metadata_extractor(metadata_extractor_h metadata); -static int _is_file_exist (const char *filename) +static int _is_file_exist(const char *filename) { int ret = 1; if (filename) { - const char *to_access = (strstr(filename,"file://")!=NULL)? filename+7:filename; - ret = access (to_access, R_OK ); + const char *to_access = (strstr(filename, "file://") != NULL) ? filename + 7 : filename; + ret = access(to_access, R_OK); if (ret != 0) { printf("file [%s] not found.\n", to_access); } @@ -75,6 +74,7 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) char *artist = NULL; char *title = NULL; char *album = NULL; + char *album_artist = NULL; char *genre = NULL; char *author = NULL; char *copyright = NULL; @@ -92,21 +92,27 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) char *altitude = 0; char *conductor = NULL; char *unsynclyrics = NULL; - char *synclyrics_num = 0; + char *synclyrics_num = NULL; char *rec_date = NULL; char *rotate = NULL; int idx = 0; unsigned long time_info = 0; char *lyrics = NULL; - - if(metadata == NULL) - { + int video_cnt = 0; + if (metadata == NULL) { printf("Invalid handle \n"); return false; } /*Get metadata*/ + metadata_extractor_get_metadata(metadata, METADATA_HAS_AUDIO, &audio_track_cnt); + printf("audio_track_cnt = [%s]\n", audio_track_cnt); + metadata_extractor_get_metadata(metadata, METADATA_HAS_VIDEO, &video_track_cnt); + printf("video_track_cnt = [%s]\n", video_track_cnt); + if (video_track_cnt != NULL) + video_cnt = atoi(video_track_cnt); + metadata_extractor_get_metadata(metadata, METADATA_DURATION, &duration); printf("duration = [%s]\n", duration); metadata_extractor_get_metadata(metadata, METADATA_AUDIO_BITRATE, &audio_bitrate); @@ -115,18 +121,17 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) printf("audio_channel = [%s]\n", audio_channel); metadata_extractor_get_metadata(metadata, METADATA_AUDIO_SAMPLERATE, &audio_samplerate); printf("audio_samplerate = [%s]Hz\n", audio_samplerate); - metadata_extractor_get_metadata(metadata, METADATA_HAS_AUDIO, &audio_track_cnt); - printf("audio_track_cnt = [%s]\n", audio_track_cnt); - metadata_extractor_get_metadata(metadata, METADATA_VIDEO_BITRATE, &video_bitrate); - printf("video_bitrate = [%s]bps\n", video_bitrate); - metadata_extractor_get_metadata(metadata, METADATA_VIDEO_FPS, &video_fps); - printf("video_fps = [%s]\n", video_fps); - metadata_extractor_get_metadata(metadata, METADATA_VIDEO_WIDTH, &video_width); - printf("video_width = [%s]\n", video_width); - metadata_extractor_get_metadata(metadata, METADATA_VIDEO_HEIGHT, &video_height); - printf("video_height = [%s]\n", video_height); - metadata_extractor_get_metadata(metadata, METADATA_HAS_VIDEO, &video_track_cnt); - printf("video_track_cnt = [%s]\n", video_track_cnt); + + if (video_cnt > 0) { + metadata_extractor_get_metadata(metadata, METADATA_VIDEO_BITRATE, &video_bitrate); + printf("video_bitrate = [%s]bps\n", video_bitrate); + metadata_extractor_get_metadata(metadata, METADATA_VIDEO_FPS, &video_fps); + printf("video_fps = [%s]\n", video_fps); + metadata_extractor_get_metadata(metadata, METADATA_VIDEO_WIDTH, &video_width); + printf("video_width = [%s]\n", video_width); + metadata_extractor_get_metadata(metadata, METADATA_VIDEO_HEIGHT, &video_height); + printf("video_height = [%s]\n", video_height); + } metadata_extractor_get_metadata(metadata, METADATA_ARTIST, &artist); printf("artist = [%s]\n", artist); @@ -134,6 +139,8 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) printf("title = [%s]\n", title); metadata_extractor_get_metadata(metadata, METADATA_ALBUM, &album); printf("album = [%s]\n", album); + metadata_extractor_get_metadata(metadata, METADATA_ALBUM_ARTIST, &album_artist); + printf("album_artist = [%s]\n", album_artist); metadata_extractor_get_metadata(metadata, METADATA_GENRE, &genre); printf("genre = [%s]\n", genre); metadata_extractor_get_metadata(metadata, METADATA_AUTHOR, &author); @@ -168,12 +175,16 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) printf("rotate = [%s]\n", rotate); metadata_extractor_get_metadata(metadata, METADATA_SYNCLYRICS_NUM, &synclyrics_num); - int s_num = atoi(synclyrics_num); - for(idx = 0; idx < s_num; idx++) - { - metadata_extractor_get_synclyrics(metadata, idx, &time_info, &lyrics); - printf("[%2d][%6ld][%s]\n", idx, time_info, lyrics); - SAFE_FREE(lyrics); + if (synclyrics_num) { + int s_num = atoi(synclyrics_num); + for (idx = 0; idx < s_num; idx++) { + int ret = -1; + ret = metadata_extractor_get_synclyrics(metadata, idx, &time_info, &lyrics); + if (ret == 0) + printf("[%2d][%6ld][%s]\n", idx, time_info, lyrics); + + SAFE_FREE(lyrics); + } } /*Get Artwork*/ @@ -181,30 +192,33 @@ static bool __capi_metadata_extractor(metadata_extractor_h metadata) printf("artwork = [%p], artwork_size = [%d]\n", artwork, artwork_size); printf("artwork_mime = [%s]\n", artwork_mime); - /*Get Thumbnail*/ - metadata_extractor_get_frame(metadata, &video_thumbnail, &video_thumbnail_len); - printf("video_thumbnail[%p], video_thumbnail_len = [%d]\n\n", video_thumbnail, video_thumbnail_len); - - /*Get Video frame at time, extract frame of 22.5 sec and not key frame*/ - metadata_extractor_get_frame_at_time(metadata, 22500, false, &video_frame, &video_frame_len); - printf("video_frame[%p], video_frame_len = [%d]\n\n", video_frame, video_frame_len); - - SAFE_FREE(duration ); - SAFE_FREE(audio_bitrate ); - SAFE_FREE(audio_channel ); - SAFE_FREE(audio_samplerate ); - SAFE_FREE(audio_track_cnt ); - SAFE_FREE(video_bitrate ); - SAFE_FREE(video_fps ); - SAFE_FREE(video_width ); - SAFE_FREE(video_height ); - SAFE_FREE(video_track_cnt ); + if (video_cnt > 0) { + /*Get Thumbnail*/ + metadata_extractor_get_frame(metadata, &video_thumbnail, &video_thumbnail_len); + printf("video_thumbnail[%p], video_thumbnail_len = [%d]\n\n", video_thumbnail, video_thumbnail_len); + + /*Get Video frame at time, extract frame of 22.5 sec and not key frame*/ + metadata_extractor_get_frame_at_time(metadata, 22500, false, &video_frame, &video_frame_len); + printf("video_frame[%p], video_frame_len = [%d]\n\n", video_frame, video_frame_len); + } + + SAFE_FREE(audio_track_cnt); + SAFE_FREE(video_track_cnt); + SAFE_FREE(duration); + SAFE_FREE(audio_bitrate); + SAFE_FREE(audio_channel); + SAFE_FREE(audio_samplerate); + SAFE_FREE(video_bitrate); + SAFE_FREE(video_fps); + SAFE_FREE(video_width); + SAFE_FREE(video_height); SAFE_FREE(video_thumbnail); SAFE_FREE(video_frame); SAFE_FREE(artist); SAFE_FREE(title); SAFE_FREE(album); + SAFE_FREE(album_artist); SAFE_FREE(genre); SAFE_FREE(author); SAFE_FREE(copyright); @@ -234,53 +248,50 @@ int main(int argc, char *argv[]) int ret = METADATA_EXTRACTOR_ERROR_NONE; metadata_extractor_h metadata; int idx = 0; - int cnt = argc -1; + int cnt = argc - 1; bool file_test = true; -// bool file_test = false; + /* bool file_test = false; */ printf("--- metadata extractor test start ---\n\n"); - if(cnt < 1) - { + if (cnt < 1) { printf("type file path plz. [%d]\n", cnt); return 0; } ret = metadata_extractor_create(&metadata); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { - LOGE("Fail metadata_extractor_create [%d]\n", ret); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + printf("Fail metadata_extractor_create [%d]\n", ret); return 0; } - for(idx = 0; idx < cnt; idx++) - { - if (!_is_file_exist (argv[idx+1])) - { - printf("there is no file [%s]\n", argv[idx+1]); + for (idx = 0; idx < cnt; idx++) { + if (!_is_file_exist(argv[idx + 1])) { + printf("there is no file [%s]\n", argv[idx + 1]); goto exception; } - if(file_test) - { + if (file_test) { printf("Extract meta from file-----------------------\n"); - ret = metadata_extractor_set_path(metadata, argv[idx+1]); - if(ret != METADATA_EXTRACTOR_ERROR_NONE) - { - LOGE("Fail metadata_extractor_set_path [%d]\n", ret); + ret = metadata_extractor_set_path(metadata, argv[idx + 1]); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + printf("Fail metadata_extractor_set_path [%d]\n", ret); goto exception; } } -#if 0 // Comment out because of prevent defect - else - { +#if 0 /* Comment out because of prevent defect */ + else { printf("Extract meta from memory-----------------------\n"); int file_size = 0; - unsigned char * buffer = NULL; + unsigned char *buffer = NULL; /* Read file */ - READ_FROM_FILE(argv[idx+1], buffer, file_size); + READ_FROM_FILE(argv[idx + 1], buffer, file_size); ret = metadata_extractor_set_buffer(metadata, buffer, file_size); + if (ret != METADATA_EXTRACTOR_ERROR_NONE) { + printf("Fail metadata_extractor_set_buffer [%d]\n", ret); + goto exception; + } } #endif -- 2.7.4