[FFmpeg-cvslog] avformat/hls: Support metadata updates from subdemuxers
Richard Shaffer
git at videolan.org
Wed Feb 7 13:42:50 EET 2018
ffmpeg | branch: master | Richard Shaffer <rshaffer at tunein.com> | Fri Feb 2 12:59:45 2018 -0800| [651d5f963921bbd547373380e1581df9bbc83199] | committer: wm4
avformat/hls: Support metadata updates from subdemuxers
If a subdemuxer has the updated metadata event flag set, the metadata is copied
to the corresponding stream. The flag is cleared on the subdemuxer and the
appropriate event flag is set on the stream.
Signed-off-by: wm4 <nfxjfg at googlemail.com>
> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=651d5f963921bbd547373380e1581df9bbc83199
---
libavformat/hls.c | 20 ++++++++++++++++++++
1 file changed, 20 insertions(+)
diff --git a/libavformat/hls.c b/libavformat/hls.c
index 9bd54c84cc..c578bf86e3 100644
--- a/libavformat/hls.c
+++ b/libavformat/hls.c
@@ -1062,6 +1062,7 @@ static void handle_id3(AVIOContext *pb, struct playlist *pls)
/* demuxer not yet opened, defer picture attachment */
pls->id3_deferred_extra = extra_meta;
+ ff_id3v2_parse_priv_dict(&metadata, &extra_meta);
av_dict_copy(&pls->ctx->metadata, metadata, 0);
pls->id3_initial = metadata;
@@ -1960,6 +1961,7 @@ static int hls_read_header(AVFormatContext *s)
if (pls->id3_deferred_extra && pls->ctx->nb_streams == 1) {
ff_id3v2_parse_apic(pls->ctx, &pls->id3_deferred_extra);
avformat_queue_attached_pictures(pls->ctx);
+ ff_id3v2_parse_priv(pls->ctx, &pls->id3_deferred_extra);
ff_id3v2_free_extra_meta(&pls->id3_deferred_extra);
pls->id3_deferred_extra = NULL;
}
@@ -1986,6 +1988,13 @@ static int hls_read_header(AVFormatContext *s)
if (ret < 0)
goto fail;
+ /*
+ * Copy any metadata from playlist to main streams, but do not set
+ * event flags.
+ */
+ if (pls->n_main_streams)
+ av_dict_copy(&pls->main_streams[0]->metadata, pls->ctx->metadata, 0);
+
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_AUDIO);
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_VIDEO);
add_metadata_from_renditions(s, pls, AVMEDIA_TYPE_SUBTITLE);
@@ -2170,6 +2179,17 @@ static int hls_read_packet(AVFormatContext *s, AVPacket *pkt)
return ret;
}
+ // If sub-demuxer reports updated metadata, copy it to the first stream
+ // and set its AVSTREAM_EVENT_FLAG_METADATA_UPDATED flag.
+ if (pls->ctx->event_flags & AVFMT_EVENT_FLAG_METADATA_UPDATED) {
+ if (pls->n_main_streams) {
+ st = pls->main_streams[0];
+ av_dict_copy(&st->metadata, pls->ctx->metadata, 0);
+ st->event_flags |= AVSTREAM_EVENT_FLAG_METADATA_UPDATED;
+ }
+ pls->ctx->event_flags &= ~AVFMT_EVENT_FLAG_METADATA_UPDATED;
+ }
+
/* check if noheader flag has been cleared by the subdemuxer */
if (pls->has_noheader_flag && !(pls->ctx->ctx_flags & AVFMTCTX_NOHEADER)) {
pls->has_noheader_flag = 0;
More information about the ffmpeg-cvslog
mailing list