From 8fb1e5ce51a2004001678d2bd8e18581465c14d5 Mon Sep 17 00:00:00 2001 From: andrewlewis Date: Thu, 5 Aug 2021 10:36:35 +0100 Subject: [PATCH] Set StreamIndex Name as format.label in SS Issue: #9252 #minor-release PiperOrigin-RevId: 388889406 --- RELEASENOTES.md | 3 +++ .../manifest/SsManifestParser.java | 3 ++- .../manifest/SsManifestParserTest.java | 16 ++++++++++++++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index f7bc8da661..db60fb6b0e 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -154,6 +154,9 @@ playlists, so that the `PlaybackStatsListener` can derive audio format-related information. ([#9175](https://github.com/google/ExoPlayer/issues/9175)). +* SS: + * Propagate `StreamIndex` element `Name` attribute value as `Format` + label ([#9252](https://github.com/google/ExoPlayer/issues/9252)). ### 2.14.2 (2021-07-20) diff --git a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java index b8d8594049..b26e2d41d8 100644 --- a/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java +++ b/library/smoothstreaming/src/main/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParser.java @@ -192,7 +192,7 @@ public class SsManifestParser implements ParsingLoadable.Parser { * provided name, the parent element parser will be queried, and so on up the chain. * * @param key The name of the attribute. - * @return The stashed value, or null if the attribute was not be found. + * @return The stashed value, or null if the attribute was not found. */ @Nullable protected final Object getNormalizedAttribute(String key) { @@ -595,6 +595,7 @@ public class SsManifestParser implements ParsingLoadable.Parser { } putNormalizedAttribute(KEY_SUB_TYPE, subType); name = parser.getAttributeValue(null, KEY_NAME); + putNormalizedAttribute(KEY_NAME, name); url = parseRequiredString(parser, KEY_URL); maxWidth = parseInt(parser, KEY_MAX_WIDTH, Format.NO_VALUE); maxHeight = parseInt(parser, KEY_MAX_HEIGHT, Format.NO_VALUE); diff --git a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java index e5a7ee5add..320db6bad2 100644 --- a/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java +++ b/library/smoothstreaming/src/test/java/com/google/android/exoplayer2/source/smoothstreaming/manifest/SsManifestParserTest.java @@ -15,11 +15,12 @@ */ package com.google.android.exoplayer2.source.smoothstreaming.manifest; +import static com.google.common.truth.Truth.assertThat; + import android.net.Uri; import androidx.test.core.app.ApplicationProvider; import androidx.test.ext.junit.runners.AndroidJUnit4; import com.google.android.exoplayer2.testutil.TestUtil; -import java.io.IOException; import org.junit.Test; import org.junit.runner.RunWith; @@ -32,7 +33,7 @@ public final class SsManifestParserTest { /** Simple test to ensure the sample manifests parse without any exceptions being thrown. */ @Test - public void parseSmoothStreamingManifest() throws IOException { + public void parseSmoothStreamingManifest() throws Exception { SsManifestParser parser = new SsManifestParser(); parser.parse( Uri.parse("https://example.com/test.ismc"), @@ -41,4 +42,15 @@ public final class SsManifestParserTest { Uri.parse("https://example.com/test.ismc"), TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_2)); } + + @Test + public void parse_populatesFormatLabelWithStreamIndexName() throws Exception { + SsManifestParser parser = new SsManifestParser(); + SsManifest ssManifest = + parser.parse( + Uri.parse("https://example.com/test.ismc"), + TestUtil.getInputStream(ApplicationProvider.getApplicationContext(), SAMPLE_ISMC_1)); + + assertThat(ssManifest.streamElements[0].formats[0].label).isEqualTo("video"); + } }