#define MIME_TYPE_JPEG "image/jpeg"
#define MIME_TYPE_PNG "image/png"
-static int __ID3_getTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value);
-static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value);
-static int __ID3_getFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, char** value);
-static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value);
-static int __ID3_getLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value);
-static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* value);
-static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* value);
-static int __MP4_getStringItem(metadata_editor_s* _metadata, const char* itemname, char** value);
-static int __MP4_getIntegerItem(metadata_editor_s* _metadata, const char* itemname, char** value);
-static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* itemname, const char* value);
-static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* itemname, const char* value);
-#if 0
-static int __xiph_getFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, char** value);
-static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, const char* value);
-#endif
typedef enum {
METADATA_EDITOR_FORMAT_MP3 = 0, /**< MP3 File */
METADATA_EDITOR_FORMAT_MP4, /**< MP4 File */
return METADATA_EDITOR_ERROR_NONE;
}
-
-// *** This is an auxiliary function that is used to write the new value to the frame *** //
-// *** It operates with frames that exists both in ID3v1 and ID3v2 tags *** //
-static int __ID3_setTwixFrameByName(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) {
+static int __ID3_setTwixFrameByName(metadata_editor_s *_metadata, TagLib::ID3v1::Tag *tag1, TagLib::ID3v2::Tag *tag2, const char *frameID, const char *value)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
ret = __check_metadata_set_parameter(_metadata);
return METADATA_EDITOR_ERROR_NONE;
}
-// *** This function writes frames that exist only in ID3v2 tag *** //
-static int __ID3_setFrameByName(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* frameID, const char* value) {
+static int __ID3_setFrameByName(metadata_editor_s *_metadata, TagLib::ID3v2::Tag *tag2, const char *frameID, const char *value)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
ret = __check_metadata_set_parameter(_metadata);
return METADATA_EDITOR_ERROR_NONE;
}
-static int __ID3_getNumberOfPictures(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, char** value)
+static int __ID3_getNumberOfPictures(metadata_editor_s *_metadata, TagLib::ID3v2::Tag *tag2, char **value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
return METADATA_EDITOR_ERROR_NONE;
}
-// *** This function is used to set text in comment frame. It processes both ID3v1 and ID3v2 tags *** //
// *** Comment frame is different from other string-type frames. It uses CommentsFrame instead of TextIdentificationFrame *** //
-static int __ID3_setTwixCommentFrame(metadata_editor_s* _metadata, TagLib::ID3v1::Tag* tag1, TagLib::ID3v2::Tag* tag2, const char* value) {
+static int __ID3_setTwixCommentFrame(metadata_editor_s *_metadata, TagLib::ID3v1::Tag *tag1, TagLib::ID3v2::Tag *tag2, const char *value)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
ret = __check_metadata_set_parameter(_metadata);
return METADATA_EDITOR_ERROR_NONE;
}
-// *** This function is used to set text in Lyrics frame *** //
// *** Lyrics frame is different from other string-type frames and uses UnsynchronizedLyricsFrame instead of TextIdentificationFrame *** //
-static int __ID3_setLyricsFrame(metadata_editor_s* _metadata, TagLib::ID3v2::Tag* tag2, const char* value) {
+static int __ID3_setLyricsFrame(metadata_editor_s *_metadata, TagLib::ID3v2::Tag *tag2, const char *value)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
ret = __check_metadata_set_parameter(_metadata);
return METADATA_EDITOR_ERROR_NONE;
}
-static int __MP4_updateStringItem(metadata_editor_s* _metadata, const char* itemname, const char* value)
+static int __MP4_updateStringItem(metadata_editor_s *_metadata, const char *itemname, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
return METADATA_EDITOR_ERROR_NONE;
}
-static int __MP4_updateIntegerItem(metadata_editor_s* _metadata, const char* itemname, const char* value)
+static int __MP4_updateIntegerItem(metadata_editor_s *_metadata, const char *itemname, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
}
}
-static int __MP4_getNumberOfPictures(metadata_editor_s* _metadata, char** value)
+static int __MP4_getNumberOfPictures(metadata_editor_s *_metadata, char **value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
}
// *** This function is used to write string into Xiph Comment fields *** //
-static int __xiph_updateFieldValue(metadata_editor_s* _metadata, TagLib::Ogg::XiphComment* xtag, const char* fieldname, const char* value) {
+static int __xiph_updateFieldValue(metadata_editor_s *_metadata, TagLib::Ogg::XiphComment *xtag, const char *fieldname, const char *value)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
ret = __check_metadata_set_parameter(_metadata);
return METADATA_EDITOR_ERROR_NONE;
}
-static int __FLAC_getNumberOfPictures(metadata_editor_s* _metadata, char** value)
+static int __FLAC_getNumberOfPictures(metadata_editor_s *_metadata, char **value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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);
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*) _metadata->file;
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*) _metadata->file;
*value = g_strdup_printf("%u", _file->pictureList().size());
return METADATA_EDITOR_ERROR_NONE;
}
#endif
-int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int max_len) {
+static int __metadata_editor_get_file_ext(const char *file_path, char *file_ext, int max_len)
+{
int i = 0;
unsigned int path_len = strlen(file_path);
return -1;
}
-int __metadata_editor_get_file_type(const char *path) {
+static int __metadata_editor_get_file_type(const char *path)
+{
int ret = 0;
char mimetype[255] = {0, };
return METADATA_EDITOR_FORMAT_NOTYPE;
}
-static int __metadata_editor_get_picture_type(const char *path, char **type) {
+static int __metadata_editor_get_picture_type(const char *path, char **type)
+{
int ret = 0;
char mimetype[255] = {0, };
return METADATA_EDITOR_ERROR_NOT_SUPPORTED;
}
-int __metadata_editor_get_picture_info(const char *path, void **picture, size_t *size, char **type) {
+static int __metadata_editor_get_picture_info(const char *path, void **picture, size_t *size, char **type)
+{
int ret;
ret = __metadata_editor_get_picture_type(path, type);
return METADATA_EDITOR_ERROR_OPERATION_FAILED;
//IF ok.. read file
- FILE* fin = fopen(path, "rb");
+ FILE *fin = fopen(path, "rb");
size_t file_size = 0;
if (fin) {
return METADATA_EDITOR_ERROR_NONE;
}
-// *** This function is used to allocate the metadata_editor_s in memory *** //
-// *** The structure metadata_editor_s contains all information about the file *** //
-extern "C" int metadata_editor_create(metadata_editor_h *metadata) {
+extern "C" int metadata_editor_create(metadata_editor_h *metadata)
+{
metadata_editor_retvm_if(metadata == NULL, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata");
metadata_editor_s *_metadata = g_new0(metadata_editor_s, 1);
return METADATA_EDITOR_ERROR_NONE;
}
-// *** This function is used to open the file. It creates the instance that is responsible for connection with file *** //
-extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *path) {
+extern "C" int metadata_editor_set_path(metadata_editor_h metadata, const char *path)
+{
int media_type = METADATA_EDITOR_FORMAT_NOTYPE;
metadata_editor_s *_metadata = (metadata_editor_s*)metadata;
- TagLib::File* _file = NULL;
+ TagLib::File *_file = NULL;
metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata");
metadata_editor_retvm_if(!path, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid path");
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
- TagLib::MPEG::File* _file = (TagLib::MPEG::File*)metadata->file;
- TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag();
- TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag();
+ TagLib::MPEG::File *_file = (TagLib::MPEG::File*)metadata->file;
+ TagLib::ID3v1::Tag *tag1 = _file->ID3v1Tag();
+ TagLib::ID3v2::Tag *tag2 = _file->ID3v2Tag();
switch (attribute) { // Check which one of frame types was given to the function for processing
case METADATA_EDITOR_ATTR_ARTIST: return __ID3_getTwixFrameByName(metadata, tag1, tag2, "TPE1", 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
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->xiphComment(false);
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*)metadata->file;
+ TagLib::Ogg::XiphComment *xtag = _file->xiphComment(false);
if (!xtag) { // Check if we have a valid tag for processing
metadata_editor_error("Tag does not exist");
*value = NULL;
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
- TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->tag();
+ TagLib::Ogg::Vorbis::File *_file = (TagLib::Ogg::Vorbis::File*)metadata->file;
+ TagLib::Ogg::XiphComment *xtag = _file->tag();
if (!xtag) { // Check if we have a valid tag for processing
metadata_editor_error("Tag does not exist");
*value = NULL;
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
- TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->tag();
+ TagLib::Ogg::FLAC::File *_file = (TagLib::Ogg::FLAC::File*)metadata->file;
+ TagLib::Ogg::XiphComment *xtag = _file->tag();
if (!xtag) { // Check if we have a valid tag for processing
metadata_editor_error("Tag does not exist");
*value = NULL;
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
- TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)metadata->file;
- TagLib::ID3v2::Tag* tag2 = _file->tag();
+ TagLib::RIFF::WAV::File *_file = (TagLib::RIFF::WAV::File*)metadata->file;
+ TagLib::ID3v2::Tag *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");
}
#endif
-// *** This function is used to get the tag frame (field, item - each tag has its own name for data unit) from file *** //
-extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value) {
+extern "C" int metadata_editor_get_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, char **value)
+{
metadata_editor_s *_metadata = (metadata_editor_s*)metadata;
metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata");
}
}
-static int __metadata_editor_set_mp3_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_mp3_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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
- TagLib::MPEG::File* _file = (TagLib::MPEG::File*)metadata->file;
- TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag();
- TagLib::ID3v2::Tag* tag2 = _file->ID3v2Tag(true);
+ TagLib::MPEG::File *_file = (TagLib::MPEG::File*)metadata->file;
+ TagLib::ID3v1::Tag *tag1 = _file->ID3v1Tag();
+ TagLib::ID3v2::Tag *tag2 = _file->ID3v2Tag(true);
metadata_editor_retvm_if(tag2 == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating");
}
}
-static int __metadata_editor_set_mp4_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_mp4_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
}
#if 0
-static int __metadata_editor_set_flac_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_flac_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->xiphComment(true);
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*)metadata->file;
+ TagLib::Ogg::XiphComment *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");
return METADATA_EDITOR_ERROR_OPERATION_FAILED;
}
}
-static int __metadata_editor_set_ogg_vorbis_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_ogg_vorbis_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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
- TagLib::Ogg::Vorbis::File* _file = (TagLib::Ogg::Vorbis::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->tag();
+ TagLib::Ogg::Vorbis::File *_file = (TagLib::Ogg::Vorbis::File*)metadata->file;
+ TagLib::Ogg::XiphComment *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;
}
}
-static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_ogg_flac_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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
- TagLib::Ogg::FLAC::File* _file = (TagLib::Ogg::FLAC::File*)metadata->file;
- TagLib::Ogg::XiphComment* xtag = _file->tag();
+ TagLib::Ogg::FLAC::File *_file = (TagLib::Ogg::FLAC::File*)metadata->file;
+ TagLib::Ogg::XiphComment *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;
}
}
-static int __metadata_editor_set_wav_metadata(metadata_editor_s* metadata, metadata_editor_attr_e attribute, const char* value)
+static int __metadata_editor_set_wav_metadata(metadata_editor_s *metadata, metadata_editor_attr_e attribute, const char *value)
{
int ret = METADATA_EDITOR_ERROR_NONE;
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
- TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)metadata->file;
- TagLib::ID3v2::Tag* tag2 = _file->tag();
+ TagLib::RIFF::WAV::File *_file = (TagLib::RIFF::WAV::File*)metadata->file;
+ TagLib::ID3v2::Tag *tag2 = _file->tag();
// Check if the valid tag pointer exist
if (tag2 == NULL) {
metadata_editor_error("Error. ID3v2 tag was not created. Can not proceed metadata updating");
}
#endif
-// *** This function is used to modify the metadata (frame in tag). But it does not apply changes to file *** //
-extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char* value) {
+extern "C" int metadata_editor_set_metadata(metadata_editor_h metadata, metadata_editor_attr_e attribute, const char *value)
+{
- metadata_editor_s* _metadata = (metadata_editor_s*) metadata;
+ metadata_editor_s *_metadata = (metadata_editor_s*) metadata;
metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata");
switch (_metadata->filetype) {
}
}
-// *** This function apply all changes done in the tag(s) and update them to file *** //
-extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata) {
+extern "C" int metadata_editor_update_metadata(metadata_editor_h metadata)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
- metadata_editor_s* _metadata = (metadata_editor_s*) metadata;
+ metadata_editor_s *_metadata = (metadata_editor_s*) metadata;
ret = __check_metadata_set_parameter(_metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
switch (_metadata->filetype) {
case METADATA_EDITOR_FORMAT_MP3: {
- TagLib::MPEG::File* _file = (TagLib::MPEG::File*)_metadata->file;
- TagLib::ID3v1::Tag* tag1 = _file->ID3v1Tag();
+ TagLib::MPEG::File *_file = (TagLib::MPEG::File*)_metadata->file;
+ TagLib::ID3v1::Tag *tag1 = _file->ID3v1Tag();
if (!tag1 || tag1->isEmpty()) { // If no ID3v1 tag - prevent its creation
if (_file->save(TagLib::MPEG::File::ID3v2 | TagLib::MPEG::File::APE))
return NULL;
}
-static int __get_APIC(TagLib::ID3v2::Tag* tag, int index, void **picture, int *size, char **mime_type)
+static int __get_APIC(TagLib::ID3v2::Tag *tag, int index, void **picture, int *size, char **mime_type)
{
metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file.");
return METADATA_EDITOR_ERROR_NONE;
}
-static int __get_mp3_picture(metadata_editor_s* metadata, int index, void **picture, int *size, char **mime_type)
+static int __get_mp3_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
return __get_APIC(dynamic_cast<TagLib::MPEG::File*>(metadata->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)
+static int __get_mp4_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
auto tag = dynamic_cast<TagLib::MP4::Tag*>(metadata->file->tag());
metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist");
}
#if 0
-static int __get_flac_picture(metadata_editor_s* metadata, int index, void **picture, int *size, char **mime_type)
+static int __get_flac_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*) metadata->file;
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*) metadata->file;
TagLib::List<TagLib::FLAC::Picture*> lst = _file->pictureList();
if (lst.isEmpty()) {
return METADATA_EDITOR_ERROR_NONE;
}
-static int __get_wav_picture(metadata_editor_s* metadata, int index, void **picture, int *size, char **mime_type)
+static int __get_wav_picture(metadata_editor_s *metadata, int index, void **picture, int *size, char **mime_type)
{
- TagLib::RIFF::WAV::File* _file = (TagLib::RIFF::WAV::File*)metadata->file;
+ TagLib::RIFF::WAV::File *_file = (TagLib::RIFF::WAV::File*)metadata->file;
return __get_APIC(_file->tag(), index, picture, size, mime_type);
}
#endif
-// *** This function returns buffer with picture under the specified index and buffer's (picture's) size *** //
-extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **picture, int *size, char **mime_type) {
+extern "C" int metadata_editor_get_picture(metadata_editor_h metadata, int index, void **picture, int *size, char **mime_type)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
- metadata_editor_s* _metadata = (metadata_editor_s*) metadata;
+ metadata_editor_s *_metadata = (metadata_editor_s*) metadata;
ret = __check_metadata_get_parameter(_metadata, mime_type);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_get_parameter() [%d]", ret);
}
}
-static int __append_APIC(TagLib::ID3v2::Tag* tag, void *picture, size_t size, const char *mime_type)
+static int __append_APIC(TagLib::ID3v2::Tag *tag, void *picture, size_t size, const char *mime_type)
{
metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. No ID3v2 tag in file.");
return METADATA_EDITOR_ERROR_NONE;
}
-static int __append_mp3_picture(metadata_editor_s* metadata, void *picture ,size_t size, const char *mime_type)
+static int __append_mp3_picture(metadata_editor_s *metadata, void *picture ,size_t size, const char *mime_type)
{
return __append_APIC(dynamic_cast<TagLib::MPEG::File*>(metadata->file)->ID3v2Tag(true), picture, size, mime_type);
}
-static int __append_mp4_picture(metadata_editor_s* metadata, void *picture, size_t size, const char *mime_type)
+static int __append_mp4_picture(metadata_editor_s *metadata, void *picture, size_t size, const char *mime_type)
{
auto tag = dynamic_cast<TagLib::MP4::Tag*>(metadata->file->tag());
metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist");
}
#if 0
-static int __append_flac_picture(metadata_editor_s* metadata, void *picture, size_t size, const char *mime_type)
+static int __append_flac_picture(metadata_editor_s *metadata, void *picture, size_t size, const char *mime_type)
{
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*) metadata->file;
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*) metadata->file;
auto frontCover = new TagLib::FLAC::Picture;
metadata_editor_debug_fenter();
return METADATA_EDITOR_ERROR_NONE;
}
-static int __append_wav_picture(metadata_editor_s* metadata, void *picture, size_t size, const char *mime_type)
+static int __append_wav_picture(metadata_editor_s *metadata, void *picture, size_t size, const char *mime_type)
{
return __append_APIC(dynamic_cast<TagLib::ID3v2::Tag*>(metadata->file->tag()), picture, size, mime_type);
}
#endif
-// *** This function appends a cover art picture to the file *** //
-extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const char *path) {
+extern "C" int metadata_editor_append_picture(metadata_editor_h metadata, const char *path)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
void *picture = NULL;
size_t size = 0;
char *mime_type = NULL;
-
- metadata_editor_s* _metadata = (metadata_editor_s*) metadata;
+ metadata_editor_s *_metadata = (metadata_editor_s*) metadata;
ret = __check_metadata_set_parameter(_metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
return ret;
}
-static int __remove_APIC(TagLib::ID3v2::Tag* tag, int index)
+static int __remove_APIC(TagLib::ID3v2::Tag *tag, int index)
{
metadata_editor_retvm_if(tag == NULL, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Error. ID3v2 tag was not created. Can not proceed metadata updating");
return METADATA_EDITOR_ERROR_NONE;
}
-static int __remove_mp3_picture(metadata_editor_s* metadata, int index)
+static int __remove_mp3_picture(metadata_editor_s *metadata, int index)
{
return __remove_APIC(dynamic_cast<TagLib::MPEG::File*>(metadata->file)->ID3v2Tag(true), index);
}
-static int __remove_mp4_picture(metadata_editor_s* metadata, int index)
+static int __remove_mp4_picture(metadata_editor_s *metadata, int index)
{
auto tag = dynamic_cast<TagLib::MP4::Tag*>(metadata->file->tag());
metadata_editor_retvm_if(!tag, METADATA_EDITOR_ERROR_OPERATION_FAILED, "Tag does not exist");
}
#if 0
-static int __remove_flac_picture(metadata_editor_s* metadata, int index)
+static int __remove_flac_picture(metadata_editor_s *metadata, int index)
{
- TagLib::FLAC::File* _file = (TagLib::FLAC::File*) metadata->file;
+ TagLib::FLAC::File *_file = (TagLib::FLAC::File*) metadata->file;
TagLib::List<TagLib::FLAC::Picture*> lst = _file->pictureList();
if (lst.isEmpty()) {
return METADATA_EDITOR_ERROR_NONE;
}
-static int __remove_wav_picture(metadata_editor_s* metadata, int index)
+static int __remove_wav_picture(metadata_editor_s *metadata, int index)
{
return __remove_APIC(dynamic_cast<TagLib::ID3v2::Tag*>(metadata->file->tag()), index);
}
#endif
-// *** This function is used to delete picture with specified index *** //
-extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int index) {
+extern "C" int metadata_editor_remove_picture(metadata_editor_h metadata, int index)
+{
int ret = METADATA_EDITOR_ERROR_NONE;
- metadata_editor_s* _metadata = (metadata_editor_s*) metadata;
+ metadata_editor_s *_metadata = (metadata_editor_s*) metadata;
ret = __check_metadata_set_parameter(_metadata);
metadata_editor_retvm_if(ret != METADATA_EDITOR_ERROR_NONE, ret, "fail to __check_metadata_set_parameter() [%d]", ret);
}
}
-extern "C" int metadata_editor_destroy(metadata_editor_h metadata) {
+extern "C" int metadata_editor_destroy(metadata_editor_h metadata)
+{
metadata_editor_s *_metadata = (metadata_editor_s*)metadata;
metadata_editor_retvm_if(!_metadata, METADATA_EDITOR_ERROR_INVALID_PARAMETER, "Invalid metadata");