From ee4b7042cea781305283d0d8a19fb62eea1e0fc3 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 11 Dec 2014 10:08:08 +0100 Subject: decoder/ffpmeg: move code to FfmpegScanMetadata() --- src/decoder/plugins/FfmpegDecoderPlugin.cxx | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) (limited to 'src/decoder') diff --git a/src/decoder/plugins/FfmpegDecoderPlugin.cxx b/src/decoder/plugins/FfmpegDecoderPlugin.cxx index 9010b7402..67c585b34 100644 --- a/src/decoder/plugins/FfmpegDecoderPlugin.cxx +++ b/src/decoder/plugins/FfmpegDecoderPlugin.cxx @@ -491,6 +491,23 @@ FfmpegParseMetaData(Decoder &decoder, decoder_mixramp(decoder, std::move(mr)); } +static void +FfmpegScanMetadata(const AVStream &stream, + const tag_handler &handler, void *handler_ctx) +{ + FfmpegScanDictionary(stream.metadata, &handler, handler_ctx); +} + +static void +FfmpegScanMetadata(const AVFormatContext &format_context, int audio_stream, + const tag_handler &handler, void *handler_ctx) +{ + FfmpegScanDictionary(format_context.metadata, &handler, handler_ctx); + if (audio_stream >= 0) + FfmpegScanMetadata(*format_context.streams[audio_stream], + handler, handler_ctx); +} + static void ffmpeg_decode(Decoder &decoder, InputStream &input) { @@ -690,11 +707,8 @@ ffmpeg_scan_stream(InputStream &is, tag_handler_invoke_duration(handler, handler_ctx, duration); } - FfmpegScanDictionary(f->metadata, handler, handler_ctx); int idx = ffmpeg_find_audio_stream(f); - if (idx >= 0) - FfmpegScanDictionary(f->streams[idx]->metadata, - handler, handler_ctx); + FfmpegScanMetadata(*f, idx, *handler, handler_ctx); avformat_close_input(&f); return true; -- cgit v1.2.3