Fix detection of Dolby Atmos in HLS

E-AC3 with JOC is signaled using the CHANNELS attribute for HLS:
https://developer.apple.com/documentation/http_live_streaming/hls_authoring_specification_for_apple_devices/hls_authoring_specification_for_apple_devices_appendices

PiperOrigin-RevId: 277680300
This commit is contained in:
andrewlewis 2019-10-31 09:32:14 +00:00 committed by Oliver Woodman
parent f4b9042bf0
commit 7ada1a848f
2 changed files with 10 additions and 8 deletions

View File

@ -4,6 +4,7 @@
* Fix the start of audio getting truncated when transitioning to a new * Fix the start of audio getting truncated when transitioning to a new
item in a playlist of opus streams. item in a playlist of opus streams.
* Fix detection of Dolby Atmos in HLS to match the HLS authoring specification.
### 2.10.6 (2019-10-17) ### ### 2.10.6 (2019-10-17) ###

View File

@ -445,7 +445,15 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
? Util.getCodecsOfType(variant.format.codecs, C.TRACK_TYPE_AUDIO) ? Util.getCodecsOfType(variant.format.codecs, C.TRACK_TYPE_AUDIO)
: null; : null;
sampleMimeType = codecs != null ? MimeTypes.getMediaMimeType(codecs) : null; sampleMimeType = codecs != null ? MimeTypes.getMediaMimeType(codecs) : null;
int channelCount = parseChannelsAttribute(line, variableDefinitions); String channelsString =
parseOptionalStringAttr(line, REGEX_CHANNELS, variableDefinitions);
int channelCount = Format.NO_VALUE;
if (channelsString != null) {
channelCount = Integer.parseInt(Util.splitAtFirst(channelsString, "/")[0]);
if (MimeTypes.AUDIO_E_AC3.equals(sampleMimeType) && channelsString.endsWith("/JOC")) {
sampleMimeType = MimeTypes.AUDIO_E_AC3_JOC;
}
}
format = format =
Format.createAudioContainerFormat( Format.createAudioContainerFormat(
/* id= */ formatId, /* id= */ formatId,
@ -819,13 +827,6 @@ public final class HlsPlaylistParser implements ParsingLoadable.Parser<HlsPlayli
return roleFlags; return roleFlags;
} }
private static int parseChannelsAttribute(String line, Map<String, String> variableDefinitions) {
String channelsString = parseOptionalStringAttr(line, REGEX_CHANNELS, variableDefinitions);
return channelsString != null
? Integer.parseInt(Util.splitAtFirst(channelsString, "/")[0])
: Format.NO_VALUE;
}
@Nullable @Nullable
private static SchemeData parseDrmSchemeData( private static SchemeData parseDrmSchemeData(
String line, String keyFormat, Map<String, String> variableDefinitions) String line, String keyFormat, Map<String, String> variableDefinitions)