Fix invalid return of metadata_editor_append_picture() and adds debug logs. 14/233914/7
authorhj kim <backto.kim@samsung.com>
Wed, 20 May 2020 08:00:33 +0000 (17:00 +0900)
committerhj kim <backto.kim@samsung.com>
Tue, 26 May 2020 02:23:59 +0000 (02:23 +0000)
metadata_editor_set_path() can return METADATA_EDITOR_ERROR_NOT_SUPPORTED for not supported file,
but other APIs should return METADATA_EDITOR_ERROR_INVALID_PARAMETER

Change-Id: I13abc82156a0c0b98867ac9078563bc18198cbea

src/metadata_editor.cpp

index 58d5fb9..219aaeb 100755 (executable)
@@ -716,7 +716,7 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *
 
 #endif
        default:
-               metadata_editor_error("Wrong file type");
+               metadata_editor_error("Not supported file type [%d]", media_type);
                return METADATA_EDITOR_ERROR_NOT_SUPPORTED;
        }
        } catch (const std::bad_alloc &ex) {
@@ -762,6 +762,7 @@ static int __metadata_editor_get_mp3_metadata(metadata_editor_s *metadata, metad
                case METADATA_EDITOR_ATTR_PICTURE_NUM:                  return __ID3_getNumberOfPictures(metadata, tag2, value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __ID3_getLyricsFrame(metadata, tag2, value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -788,6 +789,7 @@ static int __metadata_editor_get_mp4_metadata(metadata_editor_s *metadata, metad
        case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __MP4_getStringItem(metadata, "\xA9""lyr", value);
        case METADATA_EDITOR_ATTR_PICTURE_NUM:                  return __MP4_getNumberOfPictures(metadata, value);
        default:
+               metadata_editor_error("Invalid attribute [%d]", attribute);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
 }
 }
@@ -823,6 +825,7 @@ static int __metadata_editor_get_flac_metadata(metadata_editor_s *metadata, meta
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_getFieldValue(metadata, xtag, "LYRICS", value);
                case METADATA_EDITOR_ATTR_PICTURE_NUM:                  return __FLAC_getNumberOfPictures(metadata, value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -856,6 +859,7 @@ static int __metadata_editor_get_ogg_vorbis_metadata(metadata_editor_s *metadata
                case METADATA_EDITOR_ATTR_CONDUCTOR:                    return __xiph_getFieldValue(metadata, xtag, "CONDUCTOR", value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_getFieldValue(metadata, xtag, "LYRICS", value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -889,6 +893,7 @@ static int __metadata_editor_get_ogg_flac_metadata(metadata_editor_s *metadata,
                case METADATA_EDITOR_ATTR_CONDUCTOR:                    return __xiph_getFieldValue(metadata, xtag, "CONDUCTOR", value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_getFieldValue(metadata, xtag, "LYRICS", value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -925,6 +930,7 @@ static int __metadata_editor_get_wav_metadata(metadata_editor_s *metadata, metad
                case METADATA_EDITOR_ATTR_PICTURE_NUM:                  return __ID3_getNumberOfPictures(metadata, tag2, value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __ID3_getLyricsFrame(metadata, tag2, value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -958,7 +964,7 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata
 
 #endif
        default:
-               metadata_editor_error("Wrong file type [%d]", _metadata->filetype);
+               metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -991,6 +997,7 @@ static int __metadata_editor_set_mp3_metadata(metadata_editor_s *metadata, metad
                case METADATA_EDITOR_ATTR_COMMENT:              return __ID3_setTwixCommentFrame(metadata, tag1, tag2, value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS: return __ID3_setLyricsFrame(metadata, tag2, value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1016,6 +1023,7 @@ static int __metadata_editor_set_mp4_metadata(metadata_editor_s *metadata, metad
        case METADATA_EDITOR_ATTR_CONDUCTOR:            return __MP4_updateStringItem(metadata, "cond", value);
        case METADATA_EDITOR_ATTR_UNSYNCLYRICS: return __MP4_updateStringItem(metadata, "\xA9""lyr", value);
        default:
+               metadata_editor_error("Invalid attribute [%d]", attribute);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1049,6 +1057,7 @@ static int __metadata_editor_set_flac_metadata(metadata_editor_s *metadata, meta
                case METADATA_EDITOR_ATTR_CONDUCTOR:                    return __xiph_updateFieldValue(metadata, xtag, "CONDUCTOR", value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_updateFieldValue(metadata, xtag, "LYRICS", value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1081,6 +1090,7 @@ static int __metadata_editor_set_ogg_vorbis_metadata(metadata_editor_s *metadata
                case METADATA_EDITOR_ATTR_CONDUCTOR:                    return __xiph_updateFieldValue(metadata, xtag, "CONDUCTOR", value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_updateFieldValue(metadata, xtag, "LYRICS", value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1113,6 +1123,7 @@ static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s *metadata,
                case METADATA_EDITOR_ATTR_CONDUCTOR:                    return __xiph_updateFieldValue(metadata, xtag, "CONDUCTOR", value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS:                 return __xiph_updateFieldValue(metadata, xtag, "LYRICS", value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1147,6 +1158,7 @@ static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metad
                case METADATA_EDITOR_ATTR_COMMENT:              return __ID3_setTwixCommentFrame(metadata, NULL, tag2, value);
                case METADATA_EDITOR_ATTR_UNSYNCLYRICS: return __ID3_setLyricsFrame(metadata, tag2, value);
                default:
+                       metadata_editor_error("Invalid attribute [%d]", attribute);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1180,7 +1192,7 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata
 
 #endif
        default:
-               metadata_editor_error("Wrong file type");
+               metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1223,7 +1235,7 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata)
        }
 
        default:
-               metadata_editor_error("Wrong file type");
+               metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1375,7 +1387,7 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index
                return __get_wav_picture(_metadata, index, picture, size, mime_type);
 #endif
        default:
-               metadata_editor_error("Wrong file type");
+               metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
                return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }
@@ -1482,8 +1494,8 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const
                        break;
 #endif
                default: {
-                       metadata_editor_error("Wrong file type");
-                       ret = METADATA_EDITOR_ERROR_NOT_SUPPORTED;
+                       metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
+                       ret = METADATA_EDITOR_ERROR_INVALID_PARAMETER;
                        break;
                }
        }
@@ -1594,7 +1606,7 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in
                        return __remove_wav_picture(_metadata, index);
 #endif
                default:
-                       metadata_editor_error("Wrong file type");
+                       metadata_editor_error("Invalid file type [%d]", _metadata->filetype);
                        return METADATA_EDITOR_ERROR_INVALID_PARAMETER;
        }
 }