aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/ffmpeg_decoder_plugin.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2012-02-11 19:12:02 +0100
committerMax Kellermann <max@duempel.org>2012-02-11 17:04:29 +0100
commit5d73215a8dad922c8e383f3837f3ec9e26503389 (patch)
tree8fc4b96d93a907054a05d3250f97bf4f68c6df85 /src/decoder/ffmpeg_decoder_plugin.c
parentb7356bc526dbbd6fa00d40caff2addec10ae7c7e (diff)
downloadmpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.gz
mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.tar.xz
mpd-5d73215a8dad922c8e383f3837f3ec9e26503389.zip
decoder_plugin: scan tags with callback table
Pass a callback table to scan_file() and scan_stream(), instead of returning a tag object.
Diffstat (limited to 'src/decoder/ffmpeg_decoder_plugin.c')
-rw-r--r--src/decoder/ffmpeg_decoder_plugin.c31
1 files changed, 16 insertions, 15 deletions
diff --git a/src/decoder/ffmpeg_decoder_plugin.c b/src/decoder/ffmpeg_decoder_plugin.c
index 20d24f130..6ad10026a 100644
--- a/src/decoder/ffmpeg_decoder_plugin.c
+++ b/src/decoder/ffmpeg_decoder_plugin.c
@@ -21,6 +21,7 @@
#include "decoder_api.h"
#include "audio_check.h"
#include "ffmpeg_metadata.h"
+#include "tag_handler.h"
#include <glib.h>
@@ -570,22 +571,23 @@ ffmpeg_decode(struct decoder *decoder, struct input_stream *input)
}
//no tag reading in ffmpeg, check if playable
-static struct tag *
-ffmpeg_stream_tag(struct input_stream *is)
+static bool
+ffmpeg_scan_stream(struct input_stream *is,
+ const struct tag_handler *handler, void *handler_ctx)
{
AVInputFormat *input_format = ffmpeg_probe(NULL, is);
if (input_format == NULL)
- return NULL;
+ return false;
struct mpd_ffmpeg_stream *stream = mpd_ffmpeg_stream_open(NULL, is);
if (stream == NULL)
- return NULL;
+ return false;
AVFormatContext *f = NULL;
if (mpd_ffmpeg_open_input(&f, stream->io, is->uri,
input_format) != 0) {
mpd_ffmpeg_stream_close(stream);
- return NULL;
+ return false;
}
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,6,0)
@@ -601,23 +603,22 @@ ffmpeg_stream_tag(struct input_stream *is)
av_close_input_stream(f);
#endif
mpd_ffmpeg_stream_close(stream);
- return NULL;
+ return false;
}
- struct tag *tag = tag_new();
-
- tag->time = f->duration != (int64_t)AV_NOPTS_VALUE
- ? f->duration / AV_TIME_BASE
- : 0;
+ if (f->duration != (int64_t)AV_NOPTS_VALUE)
+ tag_handler_invoke_duration(handler, handler_ctx,
+ f->duration / AV_TIME_BASE);
#if LIBAVFORMAT_VERSION_INT < AV_VERSION_INT(52,101,0)
av_metadata_conv(f, NULL, f->iformat->metadata_conv);
#endif
- ffmpeg_copy_dictionary(tag, f->metadata);
+ ffmpeg_scan_dictionary(f->metadata, handler, handler_ctx);
int idx = ffmpeg_find_audio_stream(f);
if (idx >= 0)
- ffmpeg_copy_dictionary(tag, f->streams[idx]->metadata);
+ ffmpeg_scan_dictionary(f->streams[idx]->metadata,
+ handler, handler_ctx);
#if LIBAVFORMAT_VERSION_INT >= AV_VERSION_INT(53,17,0)
avformat_close_input(&f);
@@ -626,7 +627,7 @@ ffmpeg_stream_tag(struct input_stream *is)
#endif
mpd_ffmpeg_stream_close(stream);
- return tag;
+ return true;
}
/**
@@ -745,7 +746,7 @@ const struct decoder_plugin ffmpeg_decoder_plugin = {
.name = "ffmpeg",
.init = ffmpeg_init,
.stream_decode = ffmpeg_decode,
- .stream_tag = ffmpeg_stream_tag,
+ .scan_stream = ffmpeg_scan_stream,
.suffixes = ffmpeg_suffixes,
.mime_types = ffmpeg_mime_types
};