Commit 36da5fb5 by aquilescanta Committed by Andrew Lewis

Group audio renditions by name

Allows the player to adapt between audio renditions with different
names.

PiperOrigin-RevId: 233052105
parent 891ec223
......@@ -2,6 +2,8 @@
### dev-v2 (not yet released) ###
* HLS:
* Form an adaptive track group out of audio renditions with matching name.
* `ExtractorMediaSource` renamed to `ProgressiveMediaSource`.
* Support for playing spherical videos on Daydream.
* Improve decoder re-use between playbacks. TODO: Write and link a blog post
......
......@@ -67,6 +67,9 @@ import java.util.List;
/**
* Called when the wrapper has been prepared.
*
* <p>Note: This method will be called on a later handler loop than the one on which either
* {@link #prepareWithMasterPlaylistInfo} or {@link #continuePreparing} are invoked.
*/
void onPrepared();
......@@ -203,7 +206,7 @@ import java.util.List;
this.trackGroups = trackGroups;
this.optionalTrackGroups = optionalTrackGroups;
this.primaryTrackGroupIndex = primaryTrackGroupIndex;
callback.onPrepared();
handler.post(callback::onPrepared);
}
public void maybeThrowPrepareError() throws IOException {
......
......@@ -56,6 +56,11 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
* Format information associated with the HLS url.
*/
public final Format format;
/**
* Value of the NAME attribute as defined by the #EXT-X-MEDIA tag, or empty if the HLS url is
* not associated with any name.
*/
public final String name;
/**
* Creates an HLS url from a given http url.
......@@ -74,16 +79,18 @@ public final class HlsMasterPlaylist extends HlsPlaylist {
/* bitrate= */ Format.NO_VALUE,
/* selectionFlags= */ 0,
/* language= */ null);
return new HlsUrl(url, format);
return new HlsUrl(url, format, /* name= */ "");
}
/**
* @param url See {@link #url}.
* @param format See {@link #format}.
* @param name See {@link #name}.
*/
public HlsUrl(String url, Format format) {
public HlsUrl(String url, Format format, String name) {
this.url = url;
this.format = format;
this.name = name;
}
}
......
......@@ -330,7 +330,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
frameRate,
/* initializationData= */ null,
/* selectionFlags= */ 0);
variants.add(new HlsMasterPlaylist.HlsUrl(line, format));
variants.add(new HlsMasterPlaylist.HlsUrl(line, format, /* name= */ ""));
}
}
}
......@@ -365,7 +365,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
if (isMediaTagMuxed(variants, uri)) {
muxedAudioFormat = format;
} else {
audios.add(new HlsMasterPlaylist.HlsUrl(uri, format));
audios.add(new HlsMasterPlaylist.HlsUrl(uri, format, name));
}
break;
case TYPE_SUBTITLES:
......@@ -379,7 +379,7 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
/* bitrate= */ Format.NO_VALUE,
selectionFlags,
language);
subtitles.add(new HlsMasterPlaylist.HlsUrl(uri, format));
subtitles.add(new HlsMasterPlaylist.HlsUrl(uri, format, name));
break;
case TYPE_CLOSED_CAPTIONS:
String instreamId = parseStringAttr(line, REGEX_INSTREAM_ID, variableDefinitions);
......
......@@ -49,7 +49,7 @@ import org.robolectric.annotation.Config;
public final class HlsMediaPeriodTest {
@Test
public void getSteamKeys_isCompatibleWithhHlsMasterPlaylistFilter() {
public void getSteamKeys_isCompatibleWithHlsMasterPlaylistFilter() {
HlsMasterPlaylist testMasterPlaylist =
createMasterPlaylist(
/* variants= */ Arrays.asList(
......@@ -127,7 +127,8 @@ public final class HlsMediaPeriodTest {
/* height= */ Format.NO_VALUE,
/* frameRate= */ Format.NO_VALUE,
/* initializationData= */ null,
/* selectionFlags= */ 0));
/* selectionFlags= */ 0),
/* name= */ "");
}
private static HlsUrl createAudioOnlyVariantHlsUrl(int bitrate) {
......@@ -144,15 +145,16 @@ public final class HlsMediaPeriodTest {
/* height= */ Format.NO_VALUE,
/* frameRate= */ Format.NO_VALUE,
/* initializationData= */ null,
/* selectionFlags= */ 0));
/* selectionFlags= */ 0),
/* name= */ "");
}
private static HlsUrl createAudioHlsUrl(String language) {
return new HlsUrl("http://url", createAudioFormat(language));
return new HlsUrl("http://url", createAudioFormat(language), /* name= */ "");
}
private static HlsUrl createSubtitleHlsUrl(String language) {
return new HlsUrl("http://url", createSubtitleFormat(language));
return new HlsUrl("http://url", createSubtitleFormat(language), /* name= */ "");
}
private static Format createAudioFormat(String language) {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment