From: hj kim Date: Tue, 26 May 2020 07:05:01 +0000 (+0900) Subject: Support metadata editing for Wav format X-Git-Tag: submit/tizen/20200630.005817~5 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=2de567c89e47a61914414ee50f6087cf2bac3443;p=platform%2Fcore%2Fapi%2Fmetadata-editor.git Support metadata editing for Wav format Change-Id: I63654c0e4bb728e5fd8b3b247626094960130a14 --- diff --git a/src/metadata_editor.cpp b/src/metadata_editor.cpp index 8d5e7f1..172c35d 100755 --- a/src/metadata_editor.cpp +++ b/src/metadata_editor.cpp @@ -475,6 +475,8 @@ static int __metadata_editor_get_file_type(const char *path) return METADATA_EDITOR_FORMAT_MP3; else if (strcasecmp(ext, "MP4") == 0) return METADATA_EDITOR_FORMAT_MP4; + else if (strcasecmp(ext, "WAV") == 0) + return METADATA_EDITOR_FORMAT_WAV; else return METADATA_EDITOR_FORMAT_NOTYPE; } @@ -486,6 +488,8 @@ static int __metadata_editor_get_file_type(const char *path) return METADATA_EDITOR_FORMAT_MP3; else if (strstr(mimetype, "mp4") != NULL) return METADATA_EDITOR_FORMAT_MP4; + else if (strstr(mimetype, "wav") != NULL) + return METADATA_EDITOR_FORMAT_WAV; return METADATA_EDITOR_FORMAT_NOTYPE; } @@ -633,13 +637,13 @@ extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char * case METADATA_EDITOR_FORMAT_OGG_FLAC: _file = new Ogg::FLAC::File(path); break; +#endif case METADATA_EDITOR_FORMAT_WAV: // Allocate the file object in memory to work with it later on _file = new RIFF::WAV::File(path); break; -#endif default: metadata_editor_error("Not supported file type [%d]", media_type); return METADATA_EDITOR_ERROR_NOT_SUPPORTED; @@ -816,6 +820,7 @@ static int __metadata_editor_get_ogg_flac_metadata(metadata_editor_s *metadata, return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } +#endif static int __metadata_editor_get_wav_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, char **value) { @@ -827,12 +832,8 @@ static int __metadata_editor_get_wav_metadata(metadata_editor_s *metadata, metad auto _file = dynamic_cast(metadata->file); metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast"); - auto tag2 = _file->tag(); - metadata_editor_retvm_if(!tag2, METADATA_EDITOR_ERROR_NONE, "[No-Error] No tag"); - - return __get_ID3_tag(attribute, NULL, tag2, value); + return __get_ID3_tag(attribute, NULL, _file->tag(), value); } -#endif extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value) { @@ -857,11 +858,11 @@ extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata case METADATA_EDITOR_FORMAT_OGG_FLAC: return __metadata_editor_get_ogg_flac_metadata(_metadata, attribute, value); +#endif case METADATA_EDITOR_FORMAT_WAV: return __metadata_editor_get_wav_metadata(_metadata, attribute, value); -#endif default: metadata_editor_error("Invalid file type [%d]", _metadata->filetype); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; @@ -1030,6 +1031,7 @@ static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s *metadata, return METADATA_EDITOR_ERROR_INVALID_PARAMETER; } } +#endif static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value) { @@ -1043,7 +1045,6 @@ static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metad return __set_ID3_tag(attribute, NULL, _file->tag(), value); } -#endif extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char *value) { @@ -1068,11 +1069,10 @@ extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata case METADATA_EDITOR_FORMAT_OGG_FLAC: return __metadata_editor_set_ogg_flac_metadata(_metadata, attribute, value); - +#endif case METADATA_EDITOR_FORMAT_WAV: return __metadata_editor_set_wav_metadata(_metadata, attribute, value); -#endif default: metadata_editor_error("Invalid file type [%d]", _metadata->filetype); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; @@ -1112,8 +1112,8 @@ extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) case METADATA_EDITOR_FORMAT_FLAC: case METADATA_EDITOR_FORMAT_OGG_VORBIS: case METADATA_EDITOR_FORMAT_OGG_FLAC: - case METADATA_EDITOR_FORMAT_WAV: #endif + case METADATA_EDITOR_FORMAT_WAV: if (_metadata->file->save()) return METADATA_EDITOR_ERROR_NONE; @@ -1245,7 +1245,7 @@ static int __get_flac_picture(metadata_editor_s *metadata, int index, void **pic return METADATA_EDITOR_ERROR_NONE; } - +#endif static int __get_wav_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type) { auto _file = dynamic_cast(metadata->file); @@ -1253,7 +1253,6 @@ static int __get_wav_picture(metadata_editor_s *metadata, int index, void **pict return __get_APIC(_file->tag(), index, picture, size, mime_type); } -#endif extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **picture, int *size, char **mime_type) { @@ -1277,10 +1276,10 @@ extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index #if 0 case METADATA_EDITOR_FORMAT_FLAC: return __get_flac_picture(_metadata, index, picture, size, mime_type); - +#endif case METADATA_EDITOR_FORMAT_WAV: return __get_wav_picture(_metadata, index, picture, size, mime_type); -#endif + default: metadata_editor_error("Invalid file type [%d]", _metadata->filetype); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; @@ -1348,12 +1347,11 @@ static int __append_flac_picture(metadata_editor_s *metadata, const char *pictur return METADATA_EDITOR_ERROR_NONE; } - +#endif static int __append_wav_picture(metadata_editor_s *metadata, const char *picture, size_t size, const char *mime_type) { return __append_APIC(dynamic_cast(metadata->file->tag()), picture, size, mime_type); } -#endif extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const char *path) { @@ -1388,11 +1386,11 @@ extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const case METADATA_EDITOR_FORMAT_FLAC: ret = __append_flac_picture(_metadata, picture, size, mime_type); break; - +#endif case METADATA_EDITOR_FORMAT_WAV: ret = __append_wav_picture(_metadata, picture, size, mime_type); break; -#endif + default: { metadata_editor_error("Invalid file type [%d]", _metadata->filetype); ret = METADATA_EDITOR_ERROR_INVALID_PARAMETER; @@ -1469,12 +1467,12 @@ static int __remove_flac_picture(metadata_editor_s *metadata, int index) return METADATA_EDITOR_ERROR_NONE; } +#endif static int __remove_wav_picture(metadata_editor_s *metadata, int index) { return __remove_APIC(dynamic_cast(metadata->file->tag()), index); } -#endif extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int index) { @@ -1495,10 +1493,10 @@ extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int in #if 0 case METADATA_EDITOR_FORMAT_FLAC: return __remove_flac_picture(_metadata, index); - +#endif case METADATA_EDITOR_FORMAT_WAV: return __remove_wav_picture(_metadata, index); -#endif + default: metadata_editor_error("Invalid file type [%d]", _metadata->filetype); return METADATA_EDITOR_ERROR_INVALID_PARAMETER; @@ -1516,6 +1514,7 @@ extern "C" int metadata_editor_destroy(metadata_editor_h metadata) case METADATA_EDITOR_FORMAT_MP3: delete dynamic_cast(_metadata->file); break; + case METADATA_EDITOR_FORMAT_MP4: delete dynamic_cast(_metadata->file); break; @@ -1529,10 +1528,11 @@ extern "C" int metadata_editor_destroy(metadata_editor_h metadata) case METADATA_EDITOR_FORMAT_OGG_FLAC: delete dynamic_cast(_metadata->file); break; +#endif case METADATA_EDITOR_FORMAT_WAV: delete dynamic_cast(_metadata->file); break; -#endif + default: metadata_editor_error("Wrong file type"); return METADATA_EDITOR_ERROR_INVALID_PARAMETER;