ret = __check_metadata_get_parameter(metadata, value);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (FLAC::File*)metadata->file;
+ auto _file = dynamic_cast<FLAC::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto xtag = _file->xiphComment(false);
if (!xtag) { // Check if we have a valid tag for processing
metadata_editor_error("Tag does not exist");
ret = __check_metadata_get_parameter(metadata, value);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (Ogg::Vorbis::File*)metadata->file;
+ auto _file = dynamic_cast<Ogg::Vorbis::File*>(metadata->file);
+ 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("Tag does not exist");
ret = __check_metadata_get_parameter(metadata, value);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (Ogg::FLAC::File*)metadata->file;
+ auto _file = dynamic_cast<Ogg::FLAC::File*>(metadata->file);
+ 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("Tag does not exist");
ret = __check_metadata_get_parameter(metadata, value);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tag pointers
- auto _file = (RIFF::WAV::File*)metadata->file;
- auto tag2 = _file->tag();
+ auto _file = dynamic_cast<RIFF::WAV::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+ auto tag2 = _file->tag();
if (tag2 == NULL) { // Check if we have a valid tag for processing
metadata_editor_error("Error. ID3v2 tag does not exist. Can not proceed metadata extraction");
*value = NULL;
ret = __check_metadata_set_parameter(metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (FLAC::File*)metadata->file;
+ auto _file = dynamic_cast<FLAC::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto xtag = _file->xiphComment(true);
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");
ret = __check_metadata_set_parameter(metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (Ogg::Vorbis::File*)metadata->file;
+ auto _file = dynamic_cast<Ogg::Vorbis::File*>(metadata->file);
+ 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");
ret = __check_metadata_set_parameter(metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
- // Bring the pointer to actual file type and make tags pointers
- auto _file = (Ogg::FLAC::File*)metadata->file;
+ auto _file = dynamic_cast<Ogg::FLAC::File*>(metadata->file);
+ 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");
switch (_metadata->filetype) {
case METADATA_EDITOR_FORMAT_MP3: {
- auto _file = (MPEG::File*)_metadata->file;
+ auto _file = dynamic_cast<MPEG::File*>(_metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto tag1 = _file->ID3v1Tag();
if (!tag1 || tag1->isEmpty()) { // If no ID3v1 tag - prevent its creation
static int __get_mp3_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
- return __get_APIC(dynamic_cast<MPEG::File*>(metadata->file)->ID3v2Tag(), index, picture, size, mime_type);
+ auto _file = dynamic_cast<MPEG::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
+ return __get_APIC(_file->ID3v2Tag(), index, picture, size, mime_type);
}
static int __get_mp4_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
#if 0
static int __get_flac_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
- auto _file = (FLAC::File*) metadata->file;
+ auto _file = dynamic_cast<FLAC::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto lst = _file->pictureList();
if (lst.isEmpty()) {
static int __get_wav_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
- auto _file = (RIFF::WAV::File*)metadata->file;
+ auto _file = dynamic_cast<RIFF::WAV::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
return __get_APIC(_file->tag(), index, picture, size, mime_type);
}
#if 0
static int __append_flac_picture(metadata_editor_s *metadata, const char *picture, size_t size, const char *mime_type)
{
- auto _file = (FLAC::File*) metadata->file;
+ auto _file = dynamic_cast<FLAC::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto frontCover = new FLAC::Picture;
metadata_editor_debug_fenter();
static int __remove_flac_picture(metadata_editor_s *metadata, int index)
{
auto _file = dynamic_cast<FLAC::File*>(metadata->file);
+ metadata_editor_retvm_if(!_file, METADATA_EDITOR_ERROR_OPERATION_FAILED, "fail to dynamic_cast");
+
auto lst = _file->pictureList();
if (lst.isEmpty()) {