Set StreamIndex Name as format.label in SS

Issue: #9252

#minor-release

PiperOrigin-RevId: 388889406
This commit is contained in:
andrewlewis 2021-08-05 10:36:35 +01:00 committed by Christos Tsilopoulos
parent 6ca0b30755
commit 8fb1e5ce51
3 changed files with 19 additions and 3 deletions

View File

@ -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)

View File

@ -192,7 +192,7 @@ public class SsManifestParser implements ParsingLoadable.Parser<SsManifest> {
* 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<SsManifest> {
}
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);

View File

@ -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");
}
}