diff options
Diffstat (limited to 'src/decoder')
-rw-r--r-- | src/decoder/ffmpeg_metadata.c | 20 | ||||
-rw-r--r-- | src/decoder/flac_metadata.c | 13 | ||||
-rw-r--r-- | src/decoder/mp4ff_decoder_plugin.c | 2 | ||||
-rw-r--r-- | src/decoder/vorbis_comments.c | 13 | ||||
-rw-r--r-- | src/decoder/wavpack_decoder_plugin.c | 27 |
5 files changed, 75 insertions, 0 deletions
diff --git a/src/decoder/ffmpeg_metadata.c b/src/decoder/ffmpeg_metadata.c index 5325c1cae..df700fc01 100644 --- a/src/decoder/ffmpeg_metadata.c +++ b/src/decoder/ffmpeg_metadata.c @@ -50,6 +50,21 @@ ffmpeg_copy_metadata(enum tag_type type, type, mt->value); } +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0) + +static void +ffmpeg_scan_pairs(AVDictionary *dict, + const struct tag_handler *handler, void *handler_ctx) +{ + AVDictionaryEntry *i = NULL; + + while ((i = av_dict_get(dict, "", i, AV_DICT_IGNORE_SUFFIX)) != NULL) + tag_handler_invoke_pair(handler, handler_ctx, + i->key, i->value); +} + +#endif + void ffmpeg_scan_dictionary(AVDictionary *dict, const struct tag_handler *handler, void *handler_ctx) @@ -62,4 +77,9 @@ ffmpeg_scan_dictionary(AVDictionary *dict, i->name != NULL; ++i) ffmpeg_copy_metadata(i->type, dict, i->name, handler, handler_ctx); + +#if LIBAVUTIL_VERSION_INT >= AV_VERSION_INT(51,5,0) + if (handler->pair != NULL) + ffmpeg_scan_pairs(dict, handler, handler_ctx); +#endif } diff --git a/src/decoder/flac_metadata.c b/src/decoder/flac_metadata.c index 9e138ef96..bd1eaf323 100644 --- a/src/decoder/flac_metadata.c +++ b/src/decoder/flac_metadata.c @@ -196,6 +196,19 @@ flac_scan_comment(const char *char_tnum, const FLAC__StreamMetadata_VorbisComment_Entry *entry, const struct tag_handler *handler, void *handler_ctx) { + if (handler->pair != NULL) { + char *name = g_strdup((const char*)entry->entry); + char *value = strchr(name, '='); + + if (value != NULL && value > name) { + *value++ = 0; + tag_handler_invoke_pair(handler, handler_ctx, + name, value); + } + + g_free(name); + } + for (const struct tag_table *i = flac_tags; i->name != NULL; ++i) if (flac_copy_comment(entry, i->name, i->type, char_tnum, handler, handler_ctx)) diff --git a/src/decoder/mp4ff_decoder_plugin.c b/src/decoder/mp4ff_decoder_plugin.c index e1e48770a..ca78a22d0 100644 --- a/src/decoder/mp4ff_decoder_plugin.c +++ b/src/decoder/mp4ff_decoder_plugin.c @@ -414,6 +414,8 @@ mp4ff_scan_stream(struct input_stream *is, mp4ff_meta_get_by_index(mp4fh, i, &item, &value); + tag_handler_invoke_pair(handler, handler_ctx, item, value); + enum tag_type type = mp4ff_tag_name_parse(item); if (type != TAG_NUM_OF_ITEM_TYPES) tag_handler_invoke_tag(handler, handler_ctx, diff --git a/src/decoder/vorbis_comments.c b/src/decoder/vorbis_comments.c index e94ee3d0a..6c2d57b72 100644 --- a/src/decoder/vorbis_comments.c +++ b/src/decoder/vorbis_comments.c @@ -106,6 +106,19 @@ static void vorbis_scan_comment(const char *comment, const struct tag_handler *handler, void *handler_ctx) { + if (handler->pair != NULL) { + char *name = g_strdup((const char*)comment); + char *value = strchr(name, '='); + + if (value != NULL && value > name) { + *value++ = 0; + tag_handler_invoke_pair(handler, handler_ctx, + name, value); + } + + g_free(name); + } + for (const struct tag_table *i = vorbis_tags; i->name != NULL; ++i) if (vorbis_copy_comment(comment, i->name, i->type, handler, handler_ctx)) diff --git a/src/decoder/wavpack_decoder_plugin.c b/src/decoder/wavpack_decoder_plugin.c index 7ba50ba32..88a4854b8 100644 --- a/src/decoder/wavpack_decoder_plugin.c +++ b/src/decoder/wavpack_decoder_plugin.c @@ -286,6 +286,19 @@ wavpack_scan_tag_item(WavpackContext *wpc, const char *name, } +static void +wavpack_scan_pair(WavpackContext *wpc, const char *name, + const struct tag_handler *handler, void *handler_ctx) +{ + char buffer[1024]; + int len = WavpackGetTagItem(wpc, name, buffer, sizeof(buffer)); + if (len <= 0 || (unsigned)len >= sizeof(buffer)) + return; + + tag_handler_invoke_pair(handler, handler_ctx, name, buffer); + +} + /* * Reads metainfo from the specified file. */ @@ -313,6 +326,20 @@ wavpack_scan_file(const char *fname, wavpack_scan_tag_item(wpc, i->name, i->type, handler, handler_ctx); + if (handler->pair != NULL) { + char name[64]; + + for (int i = 0, n = WavpackGetNumTagItems(wpc); + i < n; ++i) { + int len = WavpackGetTagItemIndexed(wpc, i, name, + sizeof(name)); + if (len <= 0 || (unsigned)len >= sizeof(name)) + continue; + + wavpack_scan_pair(wpc, name, handler, handler_ctx); + } + } + WavpackCloseFile(wpc); return true; |