Bug fix of getting number of picture in tag 96/234296/5
authorhj kim <backto.kim@samsung.com>
Mon, 25 May 2020 07:16:35 +0000 (16:16 +0900)
committerhj kim <backto.kim@samsung.com>
Wed, 27 May 2020 03:05:24 +0000 (12:05 +0900)
if there is no tag, number should be "0".

Change-Id: I6b048dac7ad51a1eba273de62593c0851fcbcf70

src/metadata_editor.cpp

index 99bc7d4..95ce276 100755 (executable)
@@ -238,9 +238,9 @@ static int __ID3_setFrameByName(ID3v2::Tag *tag2, const char *frameID, const cha
 
 static int __ID3_getNumberOfPictures(ID3v2::Tag *tag2, char **value)
 {
-       metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag does not exist. Can not process further");
+       metadata_editor_retvm_if(!value, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid value");
 
-       *value = g_strdup_printf("%u", tag2->frameListMap()["APIC"].size());
+       *value = g_strdup_printf("%u", tag2 ? tag2->frameListMap()["APIC"].size() : 0);
 
        return METADATA_EDITOR_ERROR_NONE;
 }
@@ -407,9 +407,12 @@ static int __MP4_updateIntegerItem(MP4::Tag *tag, const char *itemname, const ch
 
 static int __MP4_getNumberOfPictures(MP4::Tag *tag, char **value)
 {
-       metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist");
+       metadata_editor_retvm_if(!value, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid value");
 
-       *value = g_strdup_printf("%u", tag->contains("covr") ? tag->item("covr").toCoverArtList().size() : 0);
+       if (tag && tag->contains("covr"))
+               *value = g_strdup_printf("%u", tag->item("covr").toCoverArtList().size());
+       else
+               *value = g_strdup_printf("0");
 
        return METADATA_EDITOR_ERROR_NONE;
 }
@@ -720,7 +723,7 @@ static int __metadata_editor_get_mp4_metadata(metadata_editor_s *metadata, metad
        default:
                metadata_editor_error("Invalid attribute [%d]", attribute);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
-}
+       }
 }
 
 #if 0