aboutsummaryrefslogtreecommitdiffstats
path: root/src/decoder/mp4ff_decoder_plugin.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/decoder/mp4ff_decoder_plugin.c')
-rw-r--r--src/decoder/mp4ff_decoder_plugin.c41
1 files changed, 24 insertions, 17 deletions
diff --git a/src/decoder/mp4ff_decoder_plugin.c b/src/decoder/mp4ff_decoder_plugin.c
index cd85778f8..ca78a22d0 100644
--- a/src/decoder/mp4ff_decoder_plugin.c
+++ b/src/decoder/mp4ff_decoder_plugin.c
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2003-2010 The Music Player Daemon Project
+ * Copyright (C) 2003-2011 The Music Player Daemon Project
* http://www.musicpd.org
*
* This program is free software; you can redistribute it and/or modify
@@ -21,6 +21,7 @@
#include "decoder_api.h"
#include "audio_check.h"
#include "tag_table.h"
+#include "tag_handler.h"
#include <glib.h>
@@ -108,7 +109,8 @@ mp4_seek(void *user_data, uint64_t position)
{
struct mp4ff_input_stream *mis = user_data;
- return input_stream_seek(mis->input_stream, position, SEEK_SET, NULL)
+ return input_stream_lock_seek(mis->input_stream, position, SEEK_SET,
+ NULL)
? 0 : -1;
}
@@ -355,16 +357,17 @@ mp4_decode(struct decoder *mpd_decoder, struct input_stream *input_stream)
mp4ff_close(mp4fh);
}
-static const char *const mp4ff_tag_names[TAG_NUM_OF_ITEM_TYPES] = {
- [TAG_ALBUM_ARTIST] = "album artist",
- [TAG_COMPOSER] = "writer",
- [TAG_PERFORMER] = "band",
+static const struct tag_table mp4ff_tags[] = {
+ { "album artist", TAG_ALBUM_ARTIST },
+ { "writer", TAG_COMPOSER },
+ { "band", TAG_PERFORMER },
+ { NULL, TAG_NUM_OF_ITEM_TYPES }
};
static enum tag_type
mp4ff_tag_name_parse(const char *name)
{
- enum tag_type type = tag_table_lookup(mp4ff_tag_names, name);
+ enum tag_type type = tag_table_lookup_i(mp4ff_tags, name);
if (type == TAG_NUM_OF_ITEM_TYPES)
type = tag_name_parse_i(name);
@@ -375,8 +378,9 @@ mp4ff_tag_name_parse(const char *name)
return type;
}
-static struct tag *
-mp4_stream_tag(struct input_stream *is)
+static bool
+mp4ff_scan_stream(struct input_stream *is,
+ const struct tag_handler *handler, void *handler_ctx)
{
struct mp4ff_input_stream mis;
int32_t track;
@@ -386,23 +390,23 @@ mp4_stream_tag(struct input_stream *is)
mp4ff_t *mp4fh = mp4ff_input_stream_open(&mis, NULL, is);
if (mp4fh == NULL)
- return NULL;
+ return false;
track = mp4_get_aac_track(mp4fh, NULL, NULL, NULL);
if (track < 0) {
mp4ff_close(mp4fh);
- return NULL;
+ return false;
}
file_time = mp4ff_get_track_duration_use_offsets(mp4fh, track);
scale = mp4ff_time_scale(mp4fh, track);
if (scale < 0) {
mp4ff_close(mp4fh);
- return NULL;
+ return false;
}
- struct tag *tag = tag_new();
- tag->time = ((float)file_time) / scale + 0.5;
+ tag_handler_invoke_duration(handler, handler_ctx,
+ ((float)file_time) / scale + 0.5);
for (i = 0; i < mp4ff_meta_get_num_items(mp4fh); i++) {
char *item;
@@ -410,9 +414,12 @@ mp4_stream_tag(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_add_item(tag, type, value);
+ tag_handler_invoke_tag(handler, handler_ctx,
+ type, value);
free(item);
free(value);
@@ -420,7 +427,7 @@ mp4_stream_tag(struct input_stream *is)
mp4ff_close(mp4fh);
- return tag;
+ return true;
}
static const char *const mp4_suffixes[] = {
@@ -435,7 +442,7 @@ static const char *const mp4_mime_types[] = { "audio/mp4", "audio/m4a", NULL };
const struct decoder_plugin mp4ff_decoder_plugin = {
.name = "mp4ff",
.stream_decode = mp4_decode,
- .stream_tag = mp4_stream_tag,
+ .scan_stream = mp4ff_scan_stream,
.suffixes = mp4_suffixes,
.mime_types = mp4_mime_types,
};