Skip to content

Commit

Permalink
Experimental: Merge muxed audio format if primary is audio
Browse files Browse the repository at this point in the history
  • Loading branch information
ojw28 committed Nov 3, 2021
1 parent bc3360e commit 6b78164
Showing 1 changed file with 14 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1392,23 +1392,33 @@ private void buildTracksFromSampleStreams() {
Format sampleFormat = Assertions.checkStateNotNull(sampleQueues[i].getUpstreamFormat());
if (i == primaryExtractorTrackIndex) {
Format[] formats = new Format[chunkSourceTrackCount];
boolean mergeMuxedAudioFormat =
primaryExtractorTrackType == C.TRACK_TYPE_AUDIO && muxedAudioFormat != null;
if (chunkSourceTrackCount == 1) {
formats[0] = sampleFormat.withManifestFormatInfo(chunkSourceTrackGroup.getFormat(0));
Format playlistFormat = chunkSourceTrackGroup.getFormat(0);
if (mergeMuxedAudioFormat) {
playlistFormat = playlistFormat.withManifestFormatInfo(muxedAudioFormat);
}
formats[0] = sampleFormat.withManifestFormatInfo(playlistFormat);
} else {
for (int j = 0; j < chunkSourceTrackCount; j++) {
formats[j] = deriveFormat(chunkSourceTrackGroup.getFormat(j), sampleFormat, true);
Format playlistFormat = chunkSourceTrackGroup.getFormat(j);
if (mergeMuxedAudioFormat) {
playlistFormat = playlistFormat.withManifestFormatInfo(muxedAudioFormat);
}
formats[j] = deriveFormat(playlistFormat, sampleFormat, true);
}
}
trackGroups[i] = new TrackGroup(formats);
primaryTrackGroupIndex = i;
} else {
@Nullable
Format trackFormat =
Format playlistFormat =
primaryExtractorTrackType == C.TRACK_TYPE_VIDEO
&& MimeTypes.isAudio(sampleFormat.sampleMimeType)
? muxedAudioFormat
: null;
trackGroups[i] = new TrackGroup(deriveFormat(trackFormat, sampleFormat, false));
trackGroups[i] = new TrackGroup(deriveFormat(playlistFormat, sampleFormat, false));
}
}
this.trackGroups = createTrackGroupArrayWithDrmInfo(trackGroups);
Expand Down

0 comments on commit 6b78164

Please sign in to comment.