From 6f778eebf9c93fd04f95289c4ec09a829c094c4b Mon Sep 17 00:00:00 2001 From: Philippe Normand Date: Sat, 3 Feb 2024 11:54:41 +0000 Subject: [PATCH] dashdemux2: Basic support for container-specific-track-id tag Part-of: --- .../ext/adaptivedemux2/dash/gstdashdemux.c | 50 ++++++++++++++++++- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c index 6795ab15b1..063c5a2765 100644 --- a/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c +++ b/subprojects/gst-plugins-good/ext/adaptivedemux2/dash/gstdashdemux.c @@ -846,6 +846,7 @@ gst_dash_demux_setup_all_streams (GstDashDemux2 * demux) GstStructure *s; gchar *lang = NULL; GstTagList *tags = NULL; + gchar *track_id = NULL; active_stream = gst_mpd_client2_get_active_stream_by_index (demux->client, i); @@ -866,6 +867,46 @@ gst_dash_demux_setup_all_streams (GstDashDemux2 * demux) if (streamtype == GST_STREAM_TYPE_UNKNOWN) continue; + /* Fill container-specific track-id string */ + 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); + } + stream_id = g_strdup_printf ("%s-%d", gst_stream_type_get_name (streamtype), i); @@ -894,10 +935,15 @@ gst_dash_demux_setup_all_streams (GstDashDemux2 * 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 = gst_dash_demux_stream_new (demux->client->period_idx, stream_id);