summaryrefslogtreecommitdiff
path: root/libavformat/oggparsevorbis.c
diff options
context:
space:
mode:
authorAndrew Stone <andrew@clovar.com>2014-08-12 17:03:55 -0400
committerAnton Khirnov <anton@khirnov.net>2014-08-13 16:25:19 +0000
commitdb68ef898a3802e51b6f41fd600d0d46d058e3f8 (patch)
treec4b4d1fa52b024c5c86a318f4b5be772f23923d3 /libavformat/oggparsevorbis.c
parentcc3e88a2b9e7ecf62e4ea1c41ce1623cea67ee96 (diff)
ogg: update event_flags with STREAM_/METADATA_UPDATED whenever metadata changes.
Originally, AVFormatContext and a metadata dict were provided to ff_vorbis_comment(), but this presented issues if an AVStream was being updated or the metadata on AVFormatContext wasn't actually being updated. To remedy this, ff_vorbis_stream_comment() explicitly updates a stream's metadata and sets any necessary flags. ff_vorbis_comment() does not modify any flags, and any calls to it that update AVFormatContext's metadata (just a single call) must also update AVFormatContext.event_flags after detecting any metadata changes to the provided dictionary, as signaled by a positive return value. Signed-off-by: Anton Khirnov <anton@khirnov.net>
Diffstat (limited to 'libavformat/oggparsevorbis.c')
-rw-r--r--libavformat/oggparsevorbis.c23
1 files changed, 19 insertions, 4 deletions
diff --git a/libavformat/oggparsevorbis.c b/libavformat/oggparsevorbis.c
index 58cb4a67fc..6bd1411cdb 100644
--- a/libavformat/oggparsevorbis.c
+++ b/libavformat/oggparsevorbis.c
@@ -71,12 +71,25 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val)
return 1;
}
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st,
+ const uint8_t *buf, int size)
+{
+ int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1);
+
+ if (updates > 0) {
+ st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+ }
+
+ return updates;
+}
+
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
const uint8_t *buf, int size,
int parse_picture)
{
const uint8_t *p = buf;
const uint8_t *end = buf + size;
+ int updates = 0;
unsigned n, j;
int s;
@@ -156,10 +169,12 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
av_log(as, AV_LOG_WARNING, "Failed to parse cover art block.\n");
continue;
}
- } else if (!ogm_chapter(as, tt, ct))
+ } else if (!ogm_chapter(as, tt, ct)) {
+ updates++;
av_dict_set(m, tt, ct,
AV_DICT_DONT_STRDUP_KEY |
AV_DICT_DONT_STRDUP_VAL);
+ }
}
}
@@ -172,7 +187,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m,
ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv);
- return 0;
+ return updates;
}
/*
@@ -305,8 +320,8 @@ static int vorbis_header(AVFormatContext *s, int idx)
}
} else if (os->buf[os->pstart] == 3) {
if (os->psize > 8 &&
- ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7,
- os->psize - 8, 1) >= 0) {
+ ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7,
+ os->psize - 8) >= 0) {
unsigned new_len;
int ret = ff_replaygain_export(st, st->metadata);