From 080320609cac190b25e3b461bc5f486dcdb18261 Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sat, 3 Feb 2024 11:54:01 +0000 Subject: [PATCH] dashdemux: Basic support for container-specific-track-id tag Part-of: --- .../gst-plugins-bad/ext/dash/gstdashdemux.c | 51 ++++++++++++++++++- 1 file changed, 49 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-bad/ext/dash/gstdashdemux.c b/subprojects/gst-plugins-bad/ext/dash/gstdashdemux.c index 4e3bd2936d..6e478f1b35 100644 --- a/subprojects/gst-plugins-bad/ext/dash/gstdashdemux.c +++ b/subprojects/gst-plugins-bad/ext/dash/gstdashdemux.c @@ -796,6 +796,7 @@ gst_dash_demux_setup_all_streams (GstDashDemux * demux) GstPad *srcpad; gchar *lang = NULL; GstTagList *tags = NULL; + gchar *track_id = NULL; active_stream = gst_mpd_client_get_active_stream_by_index (demux->client, i); @@ -813,6 +814,48 @@ gst_dash_demux_setup_all_streams (GstDashDemux * demux) if (srcpad == NULL) continue; + if (active_stream->cur_adapt_set) { + /* FIXME: For CEA 608 and CEA 708 tracks we should check the Accessibility + * descriptor: + * https://dev.w3.org/html5/html-sourcing-inband-tracks/#mpegdash + * * An ISOBMFF CEA 608 caption service: the string "cc" concatenated with + * the value of the 'channel-number' field in the Accessibility descriptor + * in the ContentComponent or AdaptationSet. + * * An ISOBMFF CEA 708 caption service: the string "sn" concatenated with + * the value of the 'service-number' field in the Accessibility descriptor + * in the ContentComponent or AdaptationSet. + * * Otherwise: + */ + + /* Content of the id attribute in the ContentComponent or AdaptationSet + * element. */ + if (active_stream->cur_adapt_set->id) { + track_id = g_strdup_printf ("%d", active_stream->cur_adapt_set->id); + } else { + GList *it; + + for (it = active_stream->cur_adapt_set->ContentComponents; it; + it = it->next) { + GstMPDContentComponentNode *cc_node = it->data; + if (cc_node->id) { + track_id = g_strdup_printf ("%u", cc_node->id); + break; + } + } + /* Empty string if the id attribute is not present on either + * element. */ + if (!track_id) + track_id = g_strdup (""); + } + } + + if (track_id) { + tags = + gst_tag_list_new (GST_TAG_CONTAINER_SPECIFIC_TRACK_ID, track_id, + NULL); + g_free (track_id); + } + caps = gst_dash_demux_get_input_caps (demux, active_stream); GST_LOG_OBJECT (demux, "Creating stream %d %" GST_PTR_FORMAT, i, caps); @@ -835,10 +878,14 @@ gst_dash_demux_setup_all_streams (GstDashDemux * demux) } if (lang) { + if (!tags) + tags = gst_tag_list_new_empty (); if (gst_tag_check_language_code (lang)) - tags = gst_tag_list_new (GST_TAG_LANGUAGE_CODE, lang, NULL); + gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_LANGUAGE_CODE, + lang, NULL); else - tags = gst_tag_list_new (GST_TAG_LANGUAGE_NAME, lang, NULL); + gst_tag_list_add (tags, GST_TAG_MERGE_REPLACE, GST_TAG_LANGUAGE_NAME, + lang, NULL); } stream = (GstDashDemuxStream *)