diff options
author | Max Kellermann <max@duempel.org> | 2014-12-11 10:39:49 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2014-12-11 10:52:40 +0100 |
commit | 673336297d58af9afd61ab5689cfc8a6e996e790 (patch) | |
tree | c992f7b8fc06895deeb217349843979747aa91a1 /src/decoder/plugins/FfmpegDecoderPlugin.cxx | |
parent | ee4b7042cea781305283d0d8a19fb62eea1e0fc3 (diff) | |
download | mpd-673336297d58af9afd61ab5689cfc8a6e996e790.tar.gz mpd-673336297d58af9afd61ab5689cfc8a6e996e790.tar.xz mpd-673336297d58af9afd61ab5689cfc8a6e996e790.zip |
decoder/ffmpeg: support stream tags
Diffstat (limited to '')
-rw-r--r-- | src/decoder/plugins/FfmpegDecoderPlugin.cxx | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 67c585b34..965a479ad 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -25,6 +25,7 @@ #include "lib/ffmpeg/Domain.hxx" #include "../DecoderAPI.hxx" #include "FfmpegMetaData.hxx" +#include "tag/TagBuilder.hxx" #include "tag/TagHandler.hxx" #include "tag/ReplayGain.hxx" #include "tag/MixRamp.hxx" @@ -508,6 +509,40 @@ FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream, handler, handler_ctx); } +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0) + +static void +FfmpegScanTag(const AVFormatContext &format_context, int audio_stream, + TagBuilder &tag) +{ + FfmpegScanMetadata(format_context, audio_stream, + full_tag_handler, &tag); +} + +/** + * Check if a new stream tag was received and pass it to + * decoder_tag(). + */ +static void +FfmpegCheckTag(Decoder &decoder, InputStream &is, + AVFormatContext &format_context, int audio_stream) +{ + AVStream &stream = *format_context.streams[audio_stream]; + if ((stream.event_flags & AVSTREAM_EVENT_FLAG_METADATA_UPDATED) == 0) + /* no new metadata */ + return; + + /* clear the flag */ + stream.event_flags &= ~AVSTREAM_EVENT_FLAG_METADATA_UPDATED; + + TagBuilder tag; + FfmpegScanTag(format_context, audio_stream, tag); + if (!tag.IsEmpty()) + decoder_tag(decoder, is, tag.Commit()); +} + +#endif + static void ffmpeg_decode(Decoder &decoder, InputStream &input) { @@ -635,6 +670,10 @@ ffmpeg_decode(Decoder &decoder, InputStream &input) /* end of file */ break; +#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(56, 1, 0) + FfmpegCheckTag(decoder, input, *format_context, audio_stream); +#endif + if (packet.stream_index == audio_stream) cmd = ffmpeg_send_packet(decoder, input, &packet, codec_context, |