From 6f19706b4d7711bd5f0bbf6bed105b5004b7eaf0 Mon Sep 17 00:00:00 2001 From: Minje Ahn Date: Tue, 8 Jun 2021 08:15:02 +0900 Subject: [PATCH] [ACR-1635] Support ebook format Change-Id: I4fcd5fd424bc96ae526d95acd7afdba7636de75b Signed-off-by: Minje Ahn --- doc/media_content_doc.h | 59 +++++++++++- include/media_book.h | 181 +++++++++++++++++++++++++++++++++++ include/media_content.h | 2 +- include/media_content_type.h | 18 +++- include/media_info.h | 24 +++++ include/media_info_private.h | 11 ++- include_product/media_book.h | 181 +++++++++++++++++++++++++++++++++++ include_product/media_content.h | 2 +- include_product/media_content_type.h | 24 +++-- include_product/media_info.h | 24 +++++ include_product/media_info_private.h | 13 ++- src/media_book.c | 114 ++++++++++++++++++++++ src/media_info.c | 49 +++++++++- 13 files changed, 678 insertions(+), 24 deletions(-) create mode 100755 include/media_book.h create mode 100755 include_product/media_book.h create mode 100644 src/media_book.c diff --git a/doc/media_content_doc.h b/doc/media_content_doc.h index 082bac6..d46c6bb 100755 --- a/doc/media_content_doc.h +++ b/doc/media_content_doc.h @@ -29,7 +29,7 @@ * * @section CAPI_MEDIA_CONTENT_MODULE_OVERVIEW Overview * The Media Content API provides functions and enumerations used in the entire Content Service.\n - * The information about media items i.e. image, audio and video, are managed in the content database and + * The information about media items i.e. image, audio, video and ebook, are managed in the content database and * operations that involve database requires an active connection with the media content service.\n * During media scanning, Media Service extract media information automatically. media information include basic file info like * path, size, modified time etc and some metadata like ID3tag, EXIF, thumbnail, etc. (thumbnail extracted only in Internal and SD card storage.) \n @@ -74,10 +74,11 @@ * * * @ref CAPI_CONTENT_MEDIA_INFO_MODULE - * Provide generic information about media content items (i.e. image, audio, video and others).\n + * Provide generic information about media content items (i.e. image, audio, video, ebook and others).\n * Provide details about audio files (e.g. name, genre etc) present in the device.\n * Provide details about image files (e.g. width, height, orientation etc) present in the device.\n - * Provide details about video files (e.g. width, height, duration etc) present in the device . + * Provide details about video files (e.g. width, height, duration etc) present in the device.\n + * Provide details about ebook files (e.g. subject, author etc) present in the device. * * * @ref CAPI_CONTENT_MEDIA_PLAYLIST_MODULE @@ -103,7 +104,7 @@ * \#include * * @section CAPI_CONTENT_MEDIA_FOLDER_MODULE_OVERVIEW Overview - * A Folder is used to organize media content files i.e. image, audio, video files, in the physical storage of the device. + * A Folder is used to organize media content files i.e. image, audio, video, ebook files, in the physical storage of the device. * The Media Folder API provides functions to get basic information about existing folders e.g. folder name, path and storage type. * It also provides functions to get information related to media items present in the folder. * @@ -621,7 +622,7 @@ * * @section CAPI_CONTENT_MEDIA_VIDEO_META_MODULE_OVERVIEW Overview * The Video Metadata API provides functions to get information about video files present in the device. - * Following information about video content (#video_meta_h )is provided: + * Following information about video content (#video_meta_h) is provided: * * * @@ -750,6 +751,54 @@ * */ + +/** + * @defgroup CAPI_CONTENT_MEDIA_BOOK_META_MODULE Book Metadata + * @brief The Book Metadata API provides functions to get information about ebook files present in the device. + * + * @ingroup CAPI_CONTENT_MEDIA_INFO_MODULE + * + * @section CAPI_CONTENT_MEDIA_BOOK_META_MODULE_HEADER Required Header + * \#include + * + * @section CAPI_CONTENT_MEDIA_BOOK_META_MODULE_OVERVIEW Overview + * The Book Metadata API provides functions to get information about book files present in the device. + * Following information about book content (#book_meta_h) is provided: + *
Attribute
+ * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + * + *
AttributeFilter KeywordComments
subject#MEDIA_GENREGet from metadata if exist.
author#MEDIA_COMPOSERGet from metadata if exist.
date#MEDIA_RECORDED_DATEGet from metadata if exist.
publisher#MEDIA_COPYRIGHTGet from metadata if exist.
+ * \n + *

+ * For getting the book handle (#book_meta_h) from the media information (#media_info_h), call the media_info_get_book() function.\n + * For getting the information related to book files stored in the device call the respective get functions e.g. to get author of the ebook file + * call #book_meta_get_author() function and so on.\n + * When the book handle is no longer needed, it should be destroyed by calling #book_meta_destroy() function. + */ + /** * @defgroup CAPI_CONTENT_MEDIA_FACE_DETECTION_MODULE Face Detection * @brief The Face Detection API provides functions to detect face information about stored image files. diff --git a/include/media_book.h b/include/media_book.h new file mode 100755 index 0000000..a80a20b --- /dev/null +++ b/include/media_book.h @@ -0,0 +1,181 @@ +/* +* Copyright (c) 2021 Samsung Electronics Co., Ltd All Rights Reserved +* +* Licensed under the Apache License, Version 2.0 (the "License"); +* you may not use this file except in compliance with the License. +* You may obtain a copy of the License at +* +* http://www.apache.org/licenses/LICENSE-2.0 +* +* Unless required by applicable law or agreed to in writing, software +* distributed under the License is distributed on an "AS IS" BASIS, +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +* See the License for the specific language governing permissions and +* limitations under the License. +*/ + + +#ifndef __TIZEN_CONTENT_MEDIA_BOOK_H__ +#define __TIZEN_CONTENT_MEDIA_BOOK_H__ + +#include + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file media_book.h + * @brief This file contains the book metadata API and related functions to proceed with book metadata. \n + * Description of the book content involves: author, publisher, date, and subject. + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_BOOK_META_MODULE + * @{ + */ + +/** + * @brief Clones the book metadata. + * @details This function copies the book metadata handle from a source to destination. + * + * @since_tizen 6.5 + * + * @remarks The @a dst should be released using book_meta_destroy(). + * + * @param[out] dst The destination handle to the book metadata + * @param[in] src The source handle to the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see media_info_get_book() + * @see book_meta_destroy() + */ +int book_meta_clone(book_meta_h *dst, book_meta_h src); + +/** + * @brief Destroys the book metadata. + * @details This function frees all resources related to the book metadata handle. This handle + * can no longer be used to perform any operations. A new handle has to + * be created before the next use. + * + * @since_tizen 6.5 + * + * @param[in] book The handle to the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see book_meta_clone() + */ +int book_meta_destroy(book_meta_h book); + +/** + * @brief Gets the ID of the media of the given book metadata. + * @since_tizen 6.5 + * + * @remarks The @a media_id should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] media_id The media ID + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_media_id(book_meta_h book, char **media_id); + +/** + * @brief Gets the subject of the given book metadata. + * @details If there is no information, @a subject will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a subject should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] subject The subject of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_subject(book_meta_h book, char **subject); + +/** + * @brief Gets the author of the given book metadata. + * @details If there is no information, @a author will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a author should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] author The author of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_author(book_meta_h book, char **author); + +/** + * @brief Gets the publication date of the given book metadata. + * @details If there is no information, @a date will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a date should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] date The date of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_date(book_meta_h book, char **date); + +/** + * @brief Gets the publisher notice of the given book metadata. + * @details If there is no information, @a publisher will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a publisher should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] publisher The publisher of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_publisher(book_meta_h book, char **publisher); + +/** + *@} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__TIZEN_CONTENT_MEDIA_BOOK_H__*/ diff --git a/include/media_content.h b/include/media_content.h index e675f0b..fd08487 100755 --- a/include/media_content.h +++ b/include/media_content.h @@ -18,7 +18,6 @@ #define __TIZEN_CONTENT_MEDIA_CONTENT_H__ #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #ifdef __cplusplus extern "C" { diff --git a/include/media_content_type.h b/include/media_content_type.h index 3c3da0d..263a8b1 100755 --- a/include/media_content_type.h +++ b/include/media_content_type.h @@ -43,15 +43,16 @@ extern "C" { * @brief Enumeration for the media file format. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks Since 4.0, #MEDIA_CONTENT_TYPE_OTHERS is related to the following feature:\n - * %http://tizen.org/feature/content.scanning.others\n - * If this feature is not supported on the device, #MEDIA_CONTENT_TYPE_OTHERS type file is not scanned. + * %http://tizen.org/feature/content.scanning.others\n + * If this feature is not supported on the device, #MEDIA_CONTENT_TYPE_OTHERS type file is not scanned. */ typedef enum { - MEDIA_CONTENT_TYPE_IMAGE = 0, /** + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +/** + * @file media_book.h + * @brief This file contains the book metadata API and related functions to proceed with book metadata. \n + * Description of the book content involves: author, publisher, date, and subject. + */ + +/** + * @addtogroup CAPI_CONTENT_MEDIA_BOOK_META_MODULE + * @{ + */ + +/** + * @brief Clones the book metadata. + * @details This function copies the book metadata handle from a source to destination. + * + * @since_tizen 6.5 + * + * @remarks The @a dst should be released using book_meta_destroy(). + * + * @param[out] dst The destination handle to the book metadata + * @param[in] src The source handle to the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see media_info_get_book() + * @see book_meta_destroy() + */ +int book_meta_clone(book_meta_h *dst, book_meta_h src); + +/** + * @brief Destroys the book metadata. + * @details This function frees all resources related to the book metadata handle. This handle + * can no longer be used to perform any operations. A new handle has to + * be created before the next use. + * + * @since_tizen 6.5 + * + * @param[in] book The handle to the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + * + * @see book_meta_clone() + */ +int book_meta_destroy(book_meta_h book); + +/** + * @brief Gets the ID of the media of the given book metadata. + * @since_tizen 6.5 + * + * @remarks The @a media_id should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] media_id The media ID + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_media_id(book_meta_h book, char **media_id); + +/** + * @brief Gets the subject of the given book metadata. + * @details If there is no information, @a subject will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a subject should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] subject The subject of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_subject(book_meta_h book, char **subject); + +/** + * @brief Gets the author of the given book metadata. + * @details If there is no information, @a author will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a author should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] author The author of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_author(book_meta_h book, char **author); + +/** + * @brief Gets the publication date of the given book metadata. + * @details If there is no information, @a date will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a date should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] date The date of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_date(book_meta_h book, char **date); + +/** + * @brief Gets the publisher notice of the given book metadata. + * @details If there is no information, @a publisher will be NULL. + * + * @since_tizen 6.5 + * + * @remarks The @a publisher should be released using free(). + * + * @param[in] book The handle to the book metadata + * @param[out] publisher The publisher of the book metadata + * + * @return @c 0 on success, + * otherwise a negative error value + * + * @retval #MEDIA_CONTENT_ERROR_NONE Successful + * @retval #MEDIA_CONTENT_ERROR_INVALID_PARAMETER Invalid parameter + */ +int book_meta_get_publisher(book_meta_h book, char **publisher); + +/** + *@} + */ + +#ifdef __cplusplus +} +#endif /* __cplusplus */ + +#endif /*__TIZEN_CONTENT_MEDIA_BOOK_H__*/ diff --git a/include_product/media_content.h b/include_product/media_content.h index aa472a1..3ee302a 100755 --- a/include_product/media_content.h +++ b/include_product/media_content.h @@ -18,7 +18,6 @@ #define __TIZEN_CONTENT_MEDIA_CONTENT_H__ #include -#include #include #include #include @@ -30,6 +29,7 @@ #include #include #include +#include #include #ifdef __cplusplus diff --git a/include_product/media_content_type.h b/include_product/media_content_type.h index afc3764..422ae84 100755 --- a/include_product/media_content_type.h +++ b/include_product/media_content_type.h @@ -43,18 +43,19 @@ extern "C" { * @brief Enumeration for the media file format. * @since_tizen @if MOBILE 2.3 @elseif WEARABLE 2.3.1 @endif * @remarks Since 4.0, #MEDIA_CONTENT_TYPE_OTHERS is related to the following feature:\n - * %http://tizen.org/feature/content.scanning.others\n - * If this feature is not supported on the device, #MEDIA_CONTENT_TYPE_OTHERS type file is not scanned. + * %http://tizen.org/feature/content.scanning.others\n + * If this feature is not supported on the device, #MEDIA_CONTENT_TYPE_OTHERS type file is not scanned. */ typedef enum { - MEDIA_CONTENT_TYPE_IMAGE = 0, /** + +int book_meta_destroy(book_meta_h book) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + + g_free(_book->media_id); + g_free(_book->author); + g_free(_book->publisher); + g_free(_book->subject); + g_free(_book->date); + g_free(_book); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_clone(book_meta_h *dst, book_meta_h src) +{ + book_meta_s *_src = (book_meta_s *)src; + + content_retip_if_fail(dst); + content_retip_if_fail(src); + + book_meta_s *_dst = g_new0(book_meta_s, 1); + + _dst->media_id = g_strdup(_src->media_id); + _dst->author = g_strdup(_src->author); + _dst->date = g_strdup(_src->date); + _dst->publisher = g_strdup(_src->publisher); + _dst->subject = g_strdup(_src->subject); + + *dst = (book_meta_h)_dst; + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_get_media_id(book_meta_h book, char **media_id) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + content_retip_if_fail(media_id); + + *media_id = g_strdup(_book->media_id); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_get_subject(book_meta_h book, char **subject) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + content_retip_if_fail(subject); + + *subject = g_strdup(_book->subject); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_get_author(book_meta_h book, char **author) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + content_retip_if_fail(author); + + *author = g_strdup(_book->author); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_get_date(book_meta_h book, char **date) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + content_retip_if_fail(date); + + *date = g_strdup(_book->date); + + return MEDIA_CONTENT_ERROR_NONE; +} + +int book_meta_get_publisher(book_meta_h book, char **publisher) +{ + book_meta_s *_book = (book_meta_s *)book; + + content_retip_if_fail(book); + content_retip_if_fail(publisher); + + *publisher = g_strdup(_book->publisher); + + return MEDIA_CONTENT_ERROR_NONE; +} diff --git a/src/media_info.c b/src/media_info.c index 32da74d..4441e69 100644 --- a/src/media_info.c +++ b/src/media_info.c @@ -110,7 +110,7 @@ static void __media_info_thumbnail_completed_cb(int error, const char *path, voi return; } -static bool __media_info_isFaceRecognition_feature_supported() +static bool __media_info_isFaceRecognition_feature_supported(void) { bool isFaceRecognitionSupported = false; @@ -343,7 +343,13 @@ void _media_info_item_get_detail(sqlite3_stmt* stmt, media_info_h media) _media->audio_meta->duration = sqlite3_column_int(stmt, MEDIA_INFO_DURATION); _media->audio_meta->samplerate = sqlite3_column_int(stmt, MEDIA_INFO_SAMPLERATE); _media->audio_meta->channel = sqlite3_column_int(stmt, MEDIA_INFO_CHANNEL); + } else if (_media->media_type == MEDIA_CONTENT_TYPE_BOOK) { + _media->book_meta = g_new0(book_meta_s, 1); + _media->book_meta->subject = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_GENRE)); + _media->book_meta->author = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COMPOSER)); + _media->book_meta->date = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_RECORDED_DATE)); + _media->book_meta->publisher = g_strdup((const char *)sqlite3_column_text(stmt, MEDIA_INFO_COPYRIGHT)); } } #ifdef _USE_TVPD_MODE @@ -596,6 +602,16 @@ int media_info_destroy(media_info_h media) g_free(_media->audio_meta); } + if (_media->book_meta) { + g_free(_media->book_meta->media_id); + g_free(_media->book_meta->author); + g_free(_media->book_meta->date); + g_free(_media->book_meta->publisher); + g_free(_media->book_meta->subject); + + g_free(_media->book_meta); + } + g_free(_media); return MEDIA_CONTENT_ERROR_NONE; @@ -694,6 +710,14 @@ int media_info_clone(media_info_h *dst, media_info_h src) _dst->audio_meta->duration = _src->audio_meta->duration; _dst->audio_meta->bitrate = _src->audio_meta->bitrate; _dst->audio_meta->bitpersample = _src->audio_meta->bitpersample; + } else if (_src->media_type == MEDIA_CONTENT_TYPE_BOOK && _src->book_meta) { + _dst->book_meta = g_new0(book_meta_s, 1); + + _dst->book_meta->media_id = g_strdup(_src->book_meta->media_id); + _dst->book_meta->author = g_strdup(_src->book_meta->author); + _dst->book_meta->date = g_strdup(_src->book_meta->date); + _dst->book_meta->publisher = g_strdup(_src->book_meta->publisher); + _dst->book_meta->subject = g_strdup(_src->book_meta->subject); } *dst = (media_info_h)_dst; @@ -861,6 +885,29 @@ int media_info_get_audio(media_info_h media, audio_meta_h *audio) return ret; } +int media_info_get_book(media_info_h media, book_meta_h *book) +{ + int ret = MEDIA_CONTENT_ERROR_NONE; + + media_info_s *_media = (media_info_s*)media; + + content_retip_if_fail(media); + content_retip_if_fail(_media->media_type == MEDIA_CONTENT_TYPE_BOOK); + content_retip_if_fail(book); + + book_meta_s *_book = g_new0(book_meta_s, 1); + + _book->media_id = g_strdup(_media->media_id); + _book->author = g_strdup(_media->book_meta->author); + _book->publisher = g_strdup(_media->book_meta->publisher); + _book->date = g_strdup(_media->book_meta->date); + _book->subject = g_strdup(_media->book_meta->subject); + + *book = (book_meta_h)_book; + + return ret; +} + int media_info_get_media_id(media_info_h media, char **media_id) { media_info_s *_media = (media_info_s*)media; -- 2.7.4