From: hj kim Date: Tue, 2 Jun 2020 02:49:01 +0000 (+0900) Subject: [ACR-1560]Add new error METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE X-Git-Tag: submit/tizen/20200623.070108^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=eea1bf8e7732d752a7155f00f64a21883d49c9fc;p=platform%2Fcore%2Fapi%2Fmetadata-editor.git [ACR-1560]Add new error METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE Metadata updating doesn't support for malformed files. Before 6.0, this function returned #METADATA_EDITOR_ERROR_OPERATION_FAILED. Since 6.0, #METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE is returned in such cases. Change-Id: I5e39c35392cac4d0b7b12a294a1e29784865eabb --- diff --git a/include/metadata_editor.h b/include/metadata_editor.h index b8e890d..8d8987a 100755 --- a/include/metadata_editor.h +++ b/include/metadata_editor.h @@ -107,7 +107,9 @@ int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_att * @since_tizen @if MOBILE 2.4 @elseif WEARABLE 3.0 @endif * * @remarks The @a value should be released using free(). \n - * You must call metadata_editor_update_metadata() to apply metadata changes to the media file. Otherwise, the previous metadata will be returned when you call metadata_editor_get_metadata(). + * You must call metadata_editor_update_metadata() to apply metadata changes to the media file. Otherwise, the previous metadata will be returned when you call metadata_editor_get_metadata(). + * This function doesn't support updating metadata which is malformed. + * Before 6.0, this function returned #METADATA_EDITOR_ERROR_OPERATION_FAILED. Since 6.0, #METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE is returned in such cases. * * @param[in] metadata The handle to metadata * @param[in] attribute key attribute name to get @@ -117,6 +119,7 @@ int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_att * @retval #METADATA_EDITOR_ERROR_INVALID_PARAMETER Invalid parameter * @retval #METADATA_EDITOR_ERROR_OUT_OF_MEMORY Out of memory * @retval #METADATA_EDITOR_ERROR_OPERATION_FAILED Internal Operation Fail + * @retval #METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE Update not possible * @pre Set path to read or write metadata by calling metadata_editor_set_path() * @see metadata_editor_create() * @see metadata_editor_set_path() @@ -184,6 +187,8 @@ int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **pi * Image type of the metadata supports jpeg and png. \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 privilege http://tizen.org/privilege/mediastorage or http://tizen.org/privilege/externalstorage. + * This function doesn't support updating metadata which is malformed. + * Before 6.0, this function returned #METADATA_EDITOR_ERROR_OPERATION_FAILED. Since 6.0, #METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE is returned in such cases. * * @param[in] metadata The handle to metadata * @param[in] picture_path The path of picture for adding to the metadata @@ -194,6 +199,7 @@ int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **pi * @retval #METADATA_EDITOR_ERROR_NOT_SUPPORTED unsupported file type * @retval #METADATA_EDITOR_ERROR_OPERATION_FAILED Internal Operation Fail * @retval #METADATA_EDITOR_ERROR_PERMISSION_DENIED Permission denied + * @retval #METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE Update not possible * @pre Set path to read or write metadata by calling metadata_editor_set_path() * @see metadata_editor_create() * @see metadata_editor_set_path() diff --git a/include/metadata_editor_type.h b/include/metadata_editor_type.h index f1e55ba..9612c34 100755 --- a/include/metadata_editor_type.h +++ b/include/metadata_editor_type.h @@ -52,6 +52,7 @@ typedef enum { METADATA_EDITOR_ERROR_PERMISSION_DENIED = TIZEN_ERROR_PERMISSION_DENIED, /**< Permission denied */ METADATA_EDITOR_ERROR_NOT_SUPPORTED = TIZEN_ERROR_NOT_SUPPORTED, /**< Unsupported type */ METADATA_EDITOR_ERROR_OPERATION_FAILED = METADATA_EDITOR_ERROR_CLASS |0x01, /**< Invalid internal operation */ + METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE = METADATA_EDITOR_ERROR_CLASS |0x02, /**< Update not possible (Since 6.0)*/ } metadata_editor_error_e; diff --git a/packaging/capi-media-metadata-editor.spec b/packaging/capi-media-metadata-editor.spec index 4835d4b..c4c5dbc 100755 --- a/packaging/capi-media-metadata-editor.spec +++ b/packaging/capi-media-metadata-editor.spec @@ -1,6 +1,6 @@ Name: capi-media-metadata-editor Summary: A metadata editor library in Tizen Native API -Version: 0.1.10 +Version: 0.1.11 Release: 0 Group: Multimedia/API License: Apache-2.0 diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 800aa77..8d5e7f1 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -336,7 +336,7 @@ static int __MP4_getIntegerItem(MP4::Tag *tag, const char *itemname, char **valu static int __MP4_updateStringItem(MP4::Tag *tag, const char *itemname, const char *value) { - metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); + metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); // Get map of items directly from tag and launch a search of specific item @@ -357,7 +357,7 @@ static int __MP4_updateStringItem(MP4::Tag *tag, const char *itemname, const cha static int __MP4_updateIntegerItem(MP4::Tag *tag, const char *itemname, const char *value) { - metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); + metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); metadata_editor_retvm_if(!itemname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid itemname"); // Get map of items directly from tag and launch a search of specific item @@ -413,7 +413,7 @@ static int __xiph_getFieldValue(Ogg::XiphComment *xtag, const char *fieldname, c static int __xiph_updateFieldValue(Ogg::XiphComment *xtag, const char *fieldname, const char *value) { - metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); metadata_editor_retvm_if(!fieldname, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid fieldname"); // Check if it is a request for deletion @@ -870,7 +870,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata static int __set_ID3_tag(metadata_editor_attr_e attribute, ID3v1::Tag *tag1, ID3v2::Tag *tag2, const char *value) { - metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating"); + metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); switch (attribute) { case METADATA_EDITOR_ATTR_ARTIST: return __ID3_setTwixFrameByName(tag1, tag2, "TPE1", value); @@ -978,10 +978,8 @@ static int __metadata_editor_set_ogg_vorbis_metadata(metadata_editor_s *metadata metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast"); auto xtag = _file->tag(); - if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); - return METADATA_EDITOR_ERROR_OPERATION_FAILED; - } + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); + switch (attribute) { // Check which one of frame type was given for processing case METADATA_EDITOR_ATTR_ARTIST: return __xiph_updateFieldValue(xtag, "ARTIST", value); case METADATA_EDITOR_ATTR_TITLE: return __xiph_updateFieldValue(xtag, "TITLE", value); @@ -1012,10 +1010,8 @@ static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s *metadata, metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast"); auto xtag = _file->tag(); - if (!xtag) { // Check if we have a valid tag for processing - metadata_editor_error("Error. Xiph Comment was not created. Can not proceed metadata updating"); - return METADATA_EDITOR_ERROR_OPERATION_FAILED; - } + metadata_editor_retvm_if(!xtag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); + switch (attribute) { // Check which one of frame type was given for processing case METADATA_EDITOR_ATTR_ARTIST: return __xiph_updateFieldValue(xtag, "ARTIST", value); case METADATA_EDITOR_ATTR_TITLE: return __xiph_updateFieldValue(xtag, "TITLE", value); @@ -1293,7 +1289,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index static int __append_APIC(ID3v2::Tag *tag, const char *picture, size_t size, const char *mime_type) { - metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file."); + metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); auto pictureFrame = new ID3v2::AttachedPictureFrame(); @@ -1316,7 +1312,7 @@ static int __append_mp3_picture(metadata_editor_s *metadata, const char *picture static int __append_mp4_picture(metadata_editor_s *metadata, const char *picture, size_t size, const char *mime_type) { auto tag = dynamic_cast(metadata->file->tag()); - metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); + metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_METADATA_UPDATE_NOT_POSSIBLE, "Tag does not exist"); MP4::CoverArtList lst; auto format = MP4::CoverArt::Unknown; @@ -1435,7 +1431,7 @@ static int __remove_mp4_picture(metadata_editor_s *metadata, int index) int ret = METADATA_EDITOR_ERROR_NONE; auto tag = dynamic_cast(metadata->file->tag()); - metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist"); + metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Tag does not exist"); if (!(tag->contains("covr"))) { metadata_editor_error("No item in file. No pictures in file");