Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/FFmpeg/FFmpeg.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Shaffer <rshaffer@tunein.com>2018-02-02 23:59:45 +0300
committerwm4 <nfxjfg@googlemail.com>2018-02-07 14:33:37 +0300
commit651d5f963921bbd547373380e1581df9bbc83199 (patch)
tree9c25029646faf8e7e12285a669798326f2c6c95d
parent33d632d40e147f99aaacafd9621f696a27dbf239 (diff)
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@googlemail.com>
-rw-r--r--libavformat/hls.c20
1 files changed, 20 insertions, 0 deletions
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;