mirror of
https://github.com/androidx/media.git
synced 2025-05-04 06:00:37 +08:00
Fix ExoMediaCryptoType attachment
- Attach types for placeholder sessions. If a placeholder session will be attached and a downstream renderer doesn't know what to do with it, then this attachment is necessary to correctly determine that the renderer does not support the track. - Attach types to sample formats. Without this, if playback fails due to a CryptoException, the ExoPlaybackException that gets thrown spuriously indicates that the format's DRM type was not supported. PiperOrigin-RevId: 325214745
This commit is contained in:
parent
f29af879c0
commit
283bed8cb2
@ -780,12 +780,10 @@ import org.checkerframework.checker.nullness.qual.MonotonicNonNull;
|
|||||||
trackFormat = trackFormat.buildUpon().setAverageBitrate(icyHeaders.bitrate).build();
|
trackFormat = trackFormat.buildUpon().setAverageBitrate(icyHeaders.bitrate).build();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (trackFormat.drmInitData != null) {
|
trackFormat =
|
||||||
trackFormat =
|
trackFormat.copyWithExoMediaCryptoType(
|
||||||
trackFormat.copyWithExoMediaCryptoType(
|
drmSessionManager.getExoMediaCryptoType(
|
||||||
drmSessionManager.getExoMediaCryptoType(
|
trackFormat.drmInitData, MimeTypes.getTrackType(trackFormat.sampleMimeType)));
|
||||||
trackFormat.drmInitData, MimeTypes.getTrackType(trackFormat.sampleMimeType)));
|
|
||||||
}
|
|
||||||
trackArray[i] = new TrackGroup(trackFormat);
|
trackArray[i] = new TrackGroup(trackFormat);
|
||||||
}
|
}
|
||||||
trackState = new TrackState(new TrackGroupArray(trackArray), trackIsAudioVideoFlags);
|
trackState = new TrackState(new TrackGroupArray(trackArray), trackIsAudioVideoFlags);
|
||||||
|
@ -826,11 +826,15 @@ public class SampleQueue implements TrackOutput {
|
|||||||
* @param outputFormatHolder The output {@link FormatHolder}.
|
* @param outputFormatHolder The output {@link FormatHolder}.
|
||||||
*/
|
*/
|
||||||
private void onFormatResult(Format newFormat, FormatHolder outputFormatHolder) {
|
private void onFormatResult(Format newFormat, FormatHolder outputFormatHolder) {
|
||||||
outputFormatHolder.format = newFormat;
|
|
||||||
boolean isFirstFormat = downstreamFormat == null;
|
boolean isFirstFormat = downstreamFormat == null;
|
||||||
@Nullable DrmInitData oldDrmInitData = isFirstFormat ? null : downstreamFormat.drmInitData;
|
@Nullable DrmInitData oldDrmInitData = isFirstFormat ? null : downstreamFormat.drmInitData;
|
||||||
downstreamFormat = newFormat;
|
downstreamFormat = newFormat;
|
||||||
@Nullable DrmInitData newDrmInitData = newFormat.drmInitData;
|
@Nullable DrmInitData newDrmInitData = newFormat.drmInitData;
|
||||||
|
|
||||||
|
outputFormatHolder.format =
|
||||||
|
newFormat.copyWithExoMediaCryptoType(
|
||||||
|
drmSessionManager.getExoMediaCryptoType(
|
||||||
|
newFormat.drmInitData, MimeTypes.getTrackType(newFormat.sampleMimeType)));
|
||||||
outputFormatHolder.drmSession = currentDrmSession;
|
outputFormatHolder.drmSession = currentDrmSession;
|
||||||
if (!isFirstFormat && Util.areEqual(oldDrmInitData, newDrmInitData)) {
|
if (!isFirstFormat && Util.areEqual(oldDrmInitData, newDrmInitData)) {
|
||||||
// Nothing to do.
|
// Nothing to do.
|
||||||
|
@ -25,7 +25,6 @@ import androidx.annotation.Nullable;
|
|||||||
import com.google.android.exoplayer2.C;
|
import com.google.android.exoplayer2.C;
|
||||||
import com.google.android.exoplayer2.Format;
|
import com.google.android.exoplayer2.Format;
|
||||||
import com.google.android.exoplayer2.SeekParameters;
|
import com.google.android.exoplayer2.SeekParameters;
|
||||||
import com.google.android.exoplayer2.drm.DrmInitData;
|
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
import com.google.android.exoplayer2.drm.DrmSessionEventListener;
|
||||||
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
import com.google.android.exoplayer2.drm.DrmSessionManager;
|
||||||
import com.google.android.exoplayer2.offline.StreamKey;
|
import com.google.android.exoplayer2.offline.StreamKey;
|
||||||
@ -665,14 +664,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
Format[] formats = new Format[representations.size()];
|
Format[] formats = new Format[representations.size()];
|
||||||
for (int j = 0; j < formats.length; j++) {
|
for (int j = 0; j < formats.length; j++) {
|
||||||
Format format = representations.get(j).format;
|
Format format = representations.get(j).format;
|
||||||
DrmInitData drmInitData = format.drmInitData;
|
formats[j] =
|
||||||
if (drmInitData != null) {
|
format.copyWithExoMediaCryptoType(
|
||||||
format =
|
drmSessionManager.getExoMediaCryptoType(
|
||||||
format.copyWithExoMediaCryptoType(
|
format.drmInitData, MimeTypes.getTrackType(format.sampleMimeType)));
|
||||||
drmSessionManager.getExoMediaCryptoType(
|
|
||||||
drmInitData, MimeTypes.getTrackType(format.sampleMimeType)));
|
|
||||||
}
|
|
||||||
formats[j] = format;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
AdaptationSet firstAdaptationSet = adaptationSets.get(adaptationSetIndices[0]);
|
AdaptationSet firstAdaptationSet = adaptationSets.get(adaptationSetIndices[0]);
|
||||||
|
@ -1318,13 +1318,10 @@ import org.checkerframework.checker.nullness.qual.RequiresNonNull;
|
|||||||
Format[] exposedFormats = new Format[trackGroup.length];
|
Format[] exposedFormats = new Format[trackGroup.length];
|
||||||
for (int j = 0; j < trackGroup.length; j++) {
|
for (int j = 0; j < trackGroup.length; j++) {
|
||||||
Format format = trackGroup.getFormat(j);
|
Format format = trackGroup.getFormat(j);
|
||||||
if (format.drmInitData != null) {
|
exposedFormats[j] =
|
||||||
format =
|
format.copyWithExoMediaCryptoType(
|
||||||
format.copyWithExoMediaCryptoType(
|
drmSessionManager.getExoMediaCryptoType(
|
||||||
drmSessionManager.getExoMediaCryptoType(
|
format.drmInitData, MimeTypes.getTrackType(format.sampleMimeType)));
|
||||||
format.drmInitData, MimeTypes.getTrackType(format.sampleMimeType)));
|
|
||||||
}
|
|
||||||
exposedFormats[j] = format;
|
|
||||||
}
|
}
|
||||||
trackGroups[i] = new TrackGroup(exposedFormats);
|
trackGroups[i] = new TrackGroup(exposedFormats);
|
||||||
}
|
}
|
||||||
|
@ -266,12 +266,10 @@ import org.checkerframework.checker.nullness.compatqual.NullableType;
|
|||||||
for (int j = 0; j < manifestFormats.length; j++) {
|
for (int j = 0; j < manifestFormats.length; j++) {
|
||||||
Format manifestFormat = manifestFormats[j];
|
Format manifestFormat = manifestFormats[j];
|
||||||
exposedFormats[j] =
|
exposedFormats[j] =
|
||||||
manifestFormat.drmInitData != null
|
manifestFormat.copyWithExoMediaCryptoType(
|
||||||
? manifestFormat.copyWithExoMediaCryptoType(
|
drmSessionManager.getExoMediaCryptoType(
|
||||||
drmSessionManager.getExoMediaCryptoType(
|
manifestFormat.drmInitData,
|
||||||
manifestFormat.drmInitData,
|
MimeTypes.getTrackType(manifestFormat.sampleMimeType)));
|
||||||
MimeTypes.getTrackType(manifestFormat.sampleMimeType)))
|
|
||||||
: manifestFormat;
|
|
||||||
}
|
}
|
||||||
trackGroups[i] = new TrackGroup(exposedFormats);
|
trackGroups[i] = new TrackGroup(exposedFormats);
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user