Skip to content

Commit

Permalink
Assume that encrypted content requires secure decoders in renderer su…
Browse files Browse the repository at this point in the history
…pport checks

Issue:#5568
PiperOrigin-RevId: 247973411
  • Loading branch information
AquilesCanta authored and ojw28 committed May 15, 2019
1 parent 15688e3 commit 50c9ae0
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 70 deletions.
2 changes: 2 additions & 0 deletions RELEASENOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
([#5868](https://github.com/google/ExoPlayer/issues/5868)).
* Fix handling of line terminators in SHOUTcast ICY metadata
([#5876](https://github.com/google/ExoPlayer/issues/5876)).
* Assume that encrypted content requires secure decoders in renderer support
checks ([#5568](https://github.com/google/ExoPlayer/issues/5568)).
* Offline: Add option to remove all downloads.
* Decoders:
* Prefer codecs that advertise format support over ones that do not, even if
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
import com.google.android.exoplayer2.PlayerMessage.Target;
import com.google.android.exoplayer2.audio.AudioRendererEventListener.EventDispatcher;
import com.google.android.exoplayer2.decoder.DecoderInputBuffer;
import com.google.android.exoplayer2.drm.DrmInitData;
import com.google.android.exoplayer2.drm.DrmSessionManager;
import com.google.android.exoplayer2.drm.FrameworkMediaCrypto;
import com.google.android.exoplayer2.mediacodec.MediaCodecInfo;
Expand Down Expand Up @@ -283,25 +282,10 @@ && allowPassthrough(format.channelCount, mimeType)
// Assume the decoder outputs 16-bit PCM, unless the input is raw.
return FORMAT_UNSUPPORTED_SUBTYPE;
}
boolean requiresSecureDecryption = false;
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
for (int i = 0; i < drmInitData.schemeDataCount; i++) {
requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
}
}
List<MediaCodecInfo> decoderInfos =
getDecoderInfos(mediaCodecSelector, format, requiresSecureDecryption);
getDecoderInfos(mediaCodecSelector, format, /* requiresSecureDecoder= */ false);
if (decoderInfos.isEmpty()) {
return requiresSecureDecryption
&& !mediaCodecSelector
.getDecoderInfos(
format.sampleMimeType,
/* requiresSecureDecoder= */ false,
/* requiresTunnelingDecoder= */ false)
.isEmpty()
? FORMAT_UNSUPPORTED_DRM
: FORMAT_UNSUPPORTED_SUBTYPE;
return FORMAT_UNSUPPORTED_SUBTYPE;
}
if (!supportsFormatDrm) {
return FORMAT_UNSUPPORTED_DRM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -291,10 +291,6 @@ public static final class SchemeData implements Parcelable {
public final String mimeType;
/** The initialization data. May be null for scheme support checks only. */
public final @Nullable byte[] data;
/**
* Whether secure decryption is required.
*/
public final boolean requiresSecureDecryption;

/**
* @param uuid The {@link UUID} of the DRM scheme, or {@link C#UUID_NIL} if the data is
Expand All @@ -303,19 +299,7 @@ public static final class SchemeData implements Parcelable {
* @param data See {@link #data}.
*/
public SchemeData(UUID uuid, String mimeType, @Nullable byte[] data) {
this(uuid, mimeType, data, false);
}

/**
* @param uuid The {@link UUID} of the DRM scheme, or {@link C#UUID_NIL} if the data is
* universal (i.e. applies to all schemes).
* @param mimeType See {@link #mimeType}.
* @param data See {@link #data}.
* @param requiresSecureDecryption See {@link #requiresSecureDecryption}.
*/
public SchemeData(
UUID uuid, String mimeType, @Nullable byte[] data, boolean requiresSecureDecryption) {
this(uuid, /* licenseServerUrl= */ null, mimeType, data, requiresSecureDecryption);
this(uuid, /* licenseServerUrl= */ null, mimeType, data);
}

/**
Expand All @@ -324,27 +308,20 @@ public SchemeData(
* @param licenseServerUrl See {@link #licenseServerUrl}.
* @param mimeType See {@link #mimeType}.
* @param data See {@link #data}.
* @param requiresSecureDecryption See {@link #requiresSecureDecryption}.
*/
public SchemeData(
UUID uuid,
@Nullable String licenseServerUrl,
String mimeType,
@Nullable byte[] data,
boolean requiresSecureDecryption) {
UUID uuid, @Nullable String licenseServerUrl, String mimeType, @Nullable byte[] data) {
this.uuid = Assertions.checkNotNull(uuid);
this.licenseServerUrl = licenseServerUrl;
this.mimeType = Assertions.checkNotNull(mimeType);
this.data = data;
this.requiresSecureDecryption = requiresSecureDecryption;
}

/* package */ SchemeData(Parcel in) {
uuid = new UUID(in.readLong(), in.readLong());
licenseServerUrl = in.readString();
mimeType = Util.castNonNull(in.readString());
data = in.createByteArray();
requiresSecureDecryption = in.readByte() != 0;
}

/**
Expand Down Expand Up @@ -381,7 +358,7 @@ public boolean hasData() {
* @return The new instance.
*/
public SchemeData copyWithData(@Nullable byte[] data) {
return new SchemeData(uuid, licenseServerUrl, mimeType, data, requiresSecureDecryption);
return new SchemeData(uuid, licenseServerUrl, mimeType, data);
}

@Override
Expand Down Expand Up @@ -425,7 +402,6 @@ public void writeToParcel(Parcel dest, int flags) {
dest.writeString(licenseServerUrl);
dest.writeString(mimeType);
dest.writeByteArray(data);
dest.writeByte((byte) (requiresSecureDecryption ? 1 : 0));
}

public static final Parcelable.Creator<SchemeData> CREATOR =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -242,8 +242,7 @@ private static SchemeData getSchemeData(UUID uuid, List<SchemeData> schemeDatas)
for (int i = 0; i < schemeDatas.size(); i++) {
SchemeData schemeData = schemeDatas.get(i);
byte[] schemeDataData = Util.castNonNull(schemeData.data);
if (schemeData.requiresSecureDecryption == firstSchemeData.requiresSecureDecryption
&& Util.areEqual(schemeData.mimeType, firstSchemeData.mimeType)
if (Util.areEqual(schemeData.mimeType, firstSchemeData.mimeType)
&& Util.areEqual(schemeData.licenseServerUrl, firstSchemeData.licenseServerUrl)
&& PsshAtomUtil.isPsshAtom(schemeDataData)) {
concatenatedDataLength += schemeDataData.length;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,29 +298,26 @@ protected int supportsFormat(MediaCodecSelector mediaCodecSelector,
if (!MimeTypes.isVideo(mimeType)) {
return FORMAT_UNSUPPORTED_TYPE;
}
boolean requiresSecureDecryption = false;
DrmInitData drmInitData = format.drmInitData;
if (drmInitData != null) {
for (int i = 0; i < drmInitData.schemeDataCount; i++) {
requiresSecureDecryption |= drmInitData.get(i).requiresSecureDecryption;
}
}
// Assume encrypted content requires secure decoders.
boolean requiresSecureDecryption = drmInitData != null;
List<MediaCodecInfo> decoderInfos =
getDecoderInfos(
mediaCodecSelector,
format,
requiresSecureDecryption,
/* requiresTunnelingDecoder= */ false);
if (requiresSecureDecryption && decoderInfos.isEmpty()) {
// No secure decoders are available. Fall back to non-secure decoders.
decoderInfos =
getDecoderInfos(
mediaCodecSelector,
format,
/* requiresSecureDecoder= */ false,
/* requiresTunnelingDecoder= */ false);
}
if (decoderInfos.isEmpty()) {
return requiresSecureDecryption
&& !getDecoderInfos(
mediaCodecSelector,
format,
/* requiresSecureDecoder= */ false,
/* requiresTunnelingDecoder= */ false)
.isEmpty()
? FORMAT_UNSUPPORTED_DRM
: FORMAT_UNSUPPORTED_SUBTYPE;
return FORMAT_UNSUPPORTED_SUBTYPE;
}
if (!supportsFormatDrm(drmSessionManager, drmInitData)) {
return FORMAT_UNSUPPORTED_DRM;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -397,7 +397,6 @@ protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp)
String licenseServerUrl = null;
byte[] data = null;
UUID uuid = null;
boolean requiresSecureDecoder = false;

String schemeIdUri = xpp.getAttributeValue(null, "schemeIdUri");
if (schemeIdUri != null) {
Expand Down Expand Up @@ -431,9 +430,6 @@ protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp)
xpp.next();
if (XmlPullParserUtil.isStartTag(xpp, "ms:laurl")) {
licenseServerUrl = xpp.getAttributeValue(null, "licenseUrl");
} else if (XmlPullParserUtil.isStartTag(xpp, "widevine:license")) {
String robustnessLevel = xpp.getAttributeValue(null, "robustness_level");
requiresSecureDecoder = robustnessLevel != null && robustnessLevel.startsWith("HW");
} else if (data == null
&& XmlPullParserUtil.isStartTagIgnorePrefix(xpp, "pssh")
&& xpp.next() == XmlPullParser.TEXT) {
Expand All @@ -457,10 +453,7 @@ protected Pair<String, SchemeData> parseContentProtection(XmlPullParser xpp)
}
} while (!XmlPullParserUtil.isEndTag(xpp, "ContentProtection"));
SchemeData schemeData =
uuid != null
? new SchemeData(
uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data, requiresSecureDecoder)
: null;
uuid != null ? new SchemeData(uuid, licenseServerUrl, MimeTypes.VIDEO_MP4, data) : null;
return Pair.create(schemeType, schemeData);
}

Expand Down

0 comments on commit 50c9ae0

Please sign in to comment.