* commit 'db68ef898a3802e51b6f41fd600d0d46d058e3f8':
ogg: update event_flags with STREAM_/METADATA_UPDATED whenever metadata changes.
Conflicts:
libavformat/oggparsevorbis.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
... | ... |
@@ -138,8 +138,11 @@ static int flac_read_header(AVFormatContext *s) |
138 | 138 |
if (metadata_type == FLAC_METADATA_TYPE_VORBIS_COMMENT) { |
139 | 139 |
AVDictionaryEntry *chmask; |
140 | 140 |
|
141 |
- if (ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1)) { |
|
141 |
+ ret = ff_vorbis_comment(s, &s->metadata, buffer, metadata_size, 1); |
|
142 |
+ if (ret < 0) { |
|
142 | 143 |
av_log(s, AV_LOG_WARNING, "error parsing VorbisComment metadata\n"); |
144 |
+ } else if (ret > 0) { |
|
145 |
+ s->event_flags |= AVFMT_EVENT_FLAG_METADATA_UPDATED; |
|
143 | 146 |
} |
144 | 147 |
|
145 | 148 |
/* parse the channels mask if present */ |
... | ... |
@@ -132,6 +132,9 @@ extern const struct ogg_codec ff_vp8_codec; |
132 | 132 |
int ff_vorbis_comment(AVFormatContext *ms, AVDictionary **m, |
133 | 133 |
const uint8_t *buf, int size, int parse_picture); |
134 | 134 |
|
135 |
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, |
|
136 |
+ const uint8_t *buf, int size); |
|
137 |
+ |
|
135 | 138 |
static inline int |
136 | 139 |
ogg_find_stream (struct ogg * ogg, int serial) |
137 | 140 |
{ |
... | ... |
@@ -74,7 +74,7 @@ static int celt_header(AVFormatContext *s, int idx) |
74 | 74 |
} else if (priv && priv->extra_headers_left) { |
75 | 75 |
/* Extra headers (vorbiscomment) */ |
76 | 76 |
|
77 |
- ff_vorbis_comment(s, &st->metadata, p, os->psize, 1); |
|
77 |
+ ff_vorbis_stream_comment(s, st, p, os->psize); |
|
78 | 78 |
priv->extra_headers_left--; |
79 | 79 |
return 1; |
80 | 80 |
} else { |
... | ... |
@@ -68,7 +68,7 @@ flac_header (AVFormatContext * s, int idx) |
68 | 68 |
|
69 | 69 |
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); |
70 | 70 |
} else if (mdt == FLAC_METADATA_TYPE_VORBIS_COMMENT) { |
71 |
- ff_vorbis_comment (s, &st->metadata, os->buf + os->pstart + 4, os->psize - 4, 1); |
|
71 |
+ ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 4, os->psize - 4); |
|
72 | 72 |
} |
73 | 73 |
|
74 | 74 |
return 1; |
... | ... |
@@ -111,7 +111,7 @@ ogm_header(AVFormatContext *s, int idx) |
111 | 111 |
} else if (bytestream2_peek_byte(&p) == 3) { |
112 | 112 |
bytestream2_skip(&p, 7); |
113 | 113 |
if (bytestream2_get_bytes_left(&p) > 1) |
114 |
- ff_vorbis_comment(s, &st->metadata, p.buffer, bytestream2_get_bytes_left(&p) - 1, 1); |
|
114 |
+ ff_vorbis_stream_comment(s, st, p.buffer, bytestream2_get_bytes_left(&p) - 1); |
|
115 | 115 |
} |
116 | 116 |
|
117 | 117 |
return 1; |
... | ... |
@@ -78,7 +78,7 @@ static int opus_header(AVFormatContext *avf, int idx) |
78 | 78 |
if (priv->need_comments) { |
79 | 79 |
if (os->psize < 8 || memcmp(packet, "OpusTags", 8)) |
80 | 80 |
return AVERROR_INVALIDDATA; |
81 |
- ff_vorbis_comment(avf, &st->metadata, packet + 8, os->psize - 8, 1); |
|
81 |
+ ff_vorbis_stream_comment(avf, st, packet + 8, os->psize - 8); |
|
82 | 82 |
priv->need_comments--; |
83 | 83 |
return 1; |
84 | 84 |
} |
... | ... |
@@ -83,7 +83,7 @@ static int speex_header(AVFormatContext *s, int idx) { |
83 | 83 |
|
84 | 84 |
avpriv_set_pts_info(st, 64, 1, st->codec->sample_rate); |
85 | 85 |
} else |
86 |
- ff_vorbis_comment(s, &st->metadata, p, os->psize, 1); |
|
86 |
+ ff_vorbis_stream_comment(s, st, p, os->psize); |
|
87 | 87 |
|
88 | 88 |
spxp->seq++; |
89 | 89 |
return 1; |
... | ... |
@@ -116,7 +116,7 @@ static int theora_header(AVFormatContext *s, int idx) |
116 | 116 |
} |
117 | 117 |
break; |
118 | 118 |
case 0x81: |
119 |
- ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, os->psize - 7, 1); |
|
119 |
+ ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, os->psize - 7); |
|
120 | 120 |
case 0x82: |
121 | 121 |
if (!thp->version) |
122 | 122 |
return AVERROR_INVALIDDATA; |
... | ... |
@@ -71,12 +71,25 @@ static int ogm_chapter(AVFormatContext *as, uint8_t *key, uint8_t *val) |
71 | 71 |
return 1; |
72 | 72 |
} |
73 | 73 |
|
74 |
+int ff_vorbis_stream_comment(AVFormatContext *as, AVStream *st, |
|
75 |
+ const uint8_t *buf, int size) |
|
76 |
+{ |
|
77 |
+ int updates = ff_vorbis_comment(as, &st->metadata, buf, size, 1); |
|
78 |
+ |
|
79 |
+ if (updates > 0) { |
|
80 |
+ st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED; |
|
81 |
+ } |
|
82 |
+ |
|
83 |
+ return updates; |
|
84 |
+} |
|
85 |
+ |
|
74 | 86 |
int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, |
75 | 87 |
const uint8_t *buf, int size, |
76 | 88 |
int parse_picture) |
77 | 89 |
{ |
78 | 90 |
const uint8_t *p = buf; |
79 | 91 |
const uint8_t *end = buf + size; |
92 |
+ int updates = 0; |
|
80 | 93 |
unsigned n, j; |
81 | 94 |
int s; |
82 | 95 |
|
... | ... |
@@ -158,6 +171,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, |
158 | 158 |
continue; |
159 | 159 |
} |
160 | 160 |
} else if (!ogm_chapter(as, tt, ct)) { |
161 |
+ updates++; |
|
161 | 162 |
if (av_dict_get(*m, tt, NULL, 0)) { |
162 | 163 |
av_dict_set(m, tt, ";", AV_DICT_APPEND); |
163 | 164 |
} |
... | ... |
@@ -178,7 +192,7 @@ int ff_vorbis_comment(AVFormatContext *as, AVDictionary **m, |
178 | 178 |
|
179 | 179 |
ff_metadata_conv(m, NULL, ff_vorbiscomment_metadata_conv); |
180 | 180 |
|
181 |
- return 0; |
|
181 |
+ return updates; |
|
182 | 182 |
} |
183 | 183 |
|
184 | 184 |
/* |
... | ... |
@@ -256,8 +270,8 @@ static int vorbis_update_metadata(AVFormatContext *s, int idx) |
256 | 256 |
|
257 | 257 |
/* New metadata packet; release old data. */ |
258 | 258 |
av_dict_free(&st->metadata); |
259 |
- ret = ff_vorbis_comment(s, &st->metadata, os->buf + os->pstart + 7, |
|
260 |
- os->psize - 8, 1); |
|
259 |
+ ret = ff_vorbis_stream_comment(s, st, os->buf + os->pstart + 7, |
|
260 |
+ os->psize - 8); |
|
261 | 261 |
if (ret < 0) |
262 | 262 |
return ret; |
263 | 263 |
|