@@ -124,7 +124,7 @@ public static void setAttribute(final Element element,
124124 * <li>{@code Period} (using {@link #generatePeriodElement(Document)});</li>
125125 * <li>{@code AdaptationSet} (using {@link #generateAdaptationSetElement(Document,
126126 * ItagItem)});</li>
127- * <li>{@code Role} (using {@link #generateRoleElement(Document)});</li>
127+ * <li>{@code Role} (using {@link #generateRoleElement(Document, ItagItem )});</li>
128128 * <li>{@code Representation} (using {@link #generateRepresentationElement(Document,
129129 * ItagItem)});</li>
130130 * <li>and, for audio streams, {@code AudioChannelConfiguration} (using
@@ -144,7 +144,7 @@ public static Document generateDocumentAndDoCommonElementsGeneration(
144144
145145 generatePeriodElement (doc );
146146 generateAdaptationSetElement (doc , itagItem );
147- generateRoleElement (doc );
147+ generateRoleElement (doc , itagItem );
148148 generateRepresentationElement (doc , itagItem );
149149 if (itagItem .itagType == ItagItem .ItagType .AUDIO ) {
150150 generateAudioChannelConfigurationElement (doc , itagItem );
@@ -208,7 +208,7 @@ public static Document generateDocumentAndMpdElement(final long duration)
208208 * {@link #generateDocumentAndMpdElement(long)}.
209209 * </p>
210210 *
211- * @param doc the {@link Document} on which the the {@code <Period>} element will be appended
211+ * @param doc the {@link Document} on which the {@code <Period>} element will be appended
212212 */
213213 public static void generatePeriodElement (@ Nonnull final Document doc )
214214 throws CreationException {
@@ -249,6 +249,16 @@ public static void generateAdaptationSetElement(@Nonnull final Document doc,
249249 "the MediaFormat or its mime type is null or empty" );
250250 }
251251
252+ if (itagItem .itagType == ItagItem .ItagType .AUDIO ) {
253+ final Locale audioLocale = itagItem .getAudioLocale ();
254+ if (audioLocale != null ) {
255+ final String audioLanguage = audioLocale .getLanguage ();
256+ if (!audioLanguage .isEmpty ()) {
257+ setAttribute (adaptationSetElement , doc , "lang" , audioLanguage );
258+ }
259+ }
260+ }
261+
252262 setAttribute (adaptationSetElement , doc , "mimeType" , mediaFormat .getMimeType ());
253263 setAttribute (adaptationSetElement , doc , "subsegmentAlignment" , "true" );
254264
@@ -267,25 +277,29 @@ public static void generateAdaptationSetElement(@Nonnull final Document doc,
267277 * </p>
268278 *
269279 * <p>
270- * {@code <Role schemeIdUri="urn:mpeg:DASH:role:2011" value="main"/>}
280+ * {@code <Role schemeIdUri="urn:mpeg:DASH:role:2011" value="VALUE"/>}, where {@code VALUE} is
281+ * {@code main} for videos and audios and {@code alternate} for descriptive audio
271282 * </p>
272283 *
273284 * <p>
274285 * The {@code <AdaptationSet>} element needs to be generated before this element with
275286 * {@link #generateAdaptationSetElement(Document, ItagItem)}).
276287 * </p>
277288 *
278- * @param doc the {@link Document} on which the the {@code <Role>} element will be appended
289+ * @param doc the {@link Document} on which the {@code <Role>} element will be appended
290+ * @param itagItem the {@link ItagItem} corresponding to the stream, which must not be null
279291 */
280- public static void generateRoleElement (@ Nonnull final Document doc )
292+ public static void generateRoleElement (@ Nonnull final Document doc ,
293+ @ Nonnull final ItagItem itagItem )
281294 throws CreationException {
282295 try {
283296 final Element adaptationSetElement = (Element ) doc .getElementsByTagName (
284297 ADAPTATION_SET ).item (0 );
285298 final Element roleElement = doc .createElement (ROLE );
286299
287300 setAttribute (roleElement , doc , "schemeIdUri" , "urn:mpeg:DASH:role:2011" );
288- setAttribute (roleElement , doc , "value" , "main" );
301+ setAttribute (roleElement , doc , "value" , itagItem .isDescriptiveAudio ()
302+ ? "alternate" : "main" );
289303
290304 adaptationSetElement .appendChild (roleElement );
291305 } catch (final DOMException e ) {
@@ -302,7 +316,7 @@ public static void generateRoleElement(@Nonnull final Document doc)
302316 * {@link #generateAdaptationSetElement(Document, ItagItem)}).
303317 * </p>
304318 *
305- * @param doc the {@link Document} on which the the {@code <SegmentTimeline>} element will be
319+ * @param doc the {@link Document} on which the {@code <SegmentTimeline>} element will be
306320 * appended
307321 * @param itagItem the {@link ItagItem} to use, which must not be null
308322 */
@@ -522,7 +536,7 @@ public static void generateSegmentTemplateElement(@Nonnull final Document doc,
522536 * {@link #generateSegmentTemplateElement(Document, String, DeliveryType)}.
523537 * </p>
524538 *
525- * @param doc the {@link Document} on which the the {@code <SegmentTimeline>} element will be
539+ * @param doc the {@link Document} on which the {@code <SegmentTimeline>} element will be
526540 * appended
527541 */
528542 public static void generateSegmentTimelineElement (@ Nonnull final Document doc )
0 commit comments