HLS: Merge muxedAudioFormat into primary audio tracks

Issue: google/ExoPlayer#9608
PiperOrigin-RevId: 410236626
This commit is contained in:
olly 2021-11-16 14:27:18 +00:00 committed by tonihei
parent 16e31a8495
commit d78d349222
2 changed files with 24 additions and 13 deletions

View File

@ -2,11 +2,7 @@
### dev-v2 (not yet released) ### dev-v2 (not yet released)
* HLS: ### 2.16.1 (2021-11-11)
* Correctly populate `Format.label` for audio only HLS streams
([#9608](https://github.com/google/ExoPlayer/issues/9608)).
### 2.16.1 (2021-11-16)
* Core Library: * Core Library:
* Fix track selection issue where overriding one track group did not * Fix track selection issue where overriding one track group did not
@ -31,6 +27,9 @@
* DASH: * DASH:
* Add parsed essential and supplemental properties to the `Representation` * Add parsed essential and supplemental properties to the `Representation`
([#9579](https://github.com/google/ExoPlayer/issues/9579)). ([#9579](https://github.com/google/ExoPlayer/issues/9579)).
* HLS:
* Correctly populate `Format.label` for audio only HLS streams
([#9608](https://github.com/google/ExoPlayer/issues/9608)).
### 2.16.0 (2021-11-04) ### 2.16.0 (2021-11-04)

View File

@ -1392,23 +1392,31 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
Format sampleFormat = Assertions.checkStateNotNull(sampleQueues[i].getUpstreamFormat()); Format sampleFormat = Assertions.checkStateNotNull(sampleQueues[i].getUpstreamFormat());
if (i == primaryExtractorTrackIndex) { if (i == primaryExtractorTrackIndex) {
Format[] formats = new Format[chunkSourceTrackCount]; Format[] formats = new Format[chunkSourceTrackCount];
if (chunkSourceTrackCount == 1) { for (int j = 0; j < chunkSourceTrackCount; j++) {
formats[0] = sampleFormat.withManifestFormatInfo(chunkSourceTrackGroup.getFormat(0)); Format playlistFormat = chunkSourceTrackGroup.getFormat(j);
} else { if (primaryExtractorTrackType == C.TRACK_TYPE_AUDIO && muxedAudioFormat != null) {
for (int j = 0; j < chunkSourceTrackCount; j++) { playlistFormat = playlistFormat.withManifestFormatInfo(muxedAudioFormat);
formats[j] = deriveFormat(chunkSourceTrackGroup.getFormat(j), sampleFormat, true);
} }
// If there's only a single variant (chunkSourceTrackCount == 1) then we can safely
// retain all fields from sampleFormat. Else we need to use deriveFormat to retain only
// the fields that will be the same for all variants.
formats[j] =
chunkSourceTrackCount == 1
? sampleFormat.withManifestFormatInfo(playlistFormat)
: deriveFormat(playlistFormat, sampleFormat, /* propagateBitrates= */ true);
} }
trackGroups[i] = new TrackGroup(formats); trackGroups[i] = new TrackGroup(formats);
primaryTrackGroupIndex = i; primaryTrackGroupIndex = i;
} else { } else {
@Nullable @Nullable
Format trackFormat = Format playlistFormat =
primaryExtractorTrackType == C.TRACK_TYPE_VIDEO primaryExtractorTrackType == C.TRACK_TYPE_VIDEO
&& MimeTypes.isAudio(sampleFormat.sampleMimeType) && MimeTypes.isAudio(sampleFormat.sampleMimeType)
? muxedAudioFormat ? muxedAudioFormat
: null; : null;
trackGroups[i] = new TrackGroup(deriveFormat(trackFormat, sampleFormat, false)); trackGroups[i] =
new TrackGroup(
deriveFormat(playlistFormat, sampleFormat, /* propagateBitrates= */ false));
} }
} }
this.trackGroups = createTrackGroupArrayWithDrmInfo(trackGroups); this.trackGroups = createTrackGroupArrayWithDrmInfo(trackGroups);
@ -1496,8 +1504,12 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
* sample format that may have been obtained from a chunk belonging to a different track in the * sample format that may have been obtained from a chunk belonging to a different track in the
* same track group. * same track group.
* *
* <p>Note: Since the sample format may have been obtained from a chunk belonging to a different
* track, it should not be used as a source for data that may vary between tracks.
*
* @param playlistFormat The format information obtained from the master playlist. * @param playlistFormat The format information obtained from the master playlist.
* @param sampleFormat The format information obtained from the samples. * @param sampleFormat The format information obtained from samples within a chunk. The chunk may
* belong to a different track in the same track group.
* @param propagateBitrates Whether the bitrates from the playlist format should be included in * @param propagateBitrates Whether the bitrates from the playlist format should be included in
* the derived format. * the derived format.
* @return The derived track format. * @return The derived track format.