Remove canAcquireSession from DrmSessionManager

It's been replaced by getExoMediaCryptoType().

PiperOrigin-RevId: 323382332
This commit is contained in:
aquilescanta 2020-07-27 18:02:09 +01:00 committed by Oliver Woodman
parent 7edc4b1f1e
commit 51e65ff55a
2 changed files with 31 additions and 47 deletions

View File

@ -465,38 +465,6 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
exoMediaDrm = null;
}
@Override
public boolean canAcquireSession(DrmInitData drmInitData) {
if (offlineLicenseKeySetId != null) {
// An offline license can be restored so a session can always be acquired.
return true;
}
List<SchemeData> schemeDatas = getSchemeDatas(drmInitData, uuid, true);
if (schemeDatas.isEmpty()) {
if (drmInitData.schemeDataCount == 1 && drmInitData.get(0).matches(C.COMMON_PSSH_UUID)) {
// Assume scheme specific data will be added before the session is opened.
Log.w(
TAG, "DrmInitData only contains common PSSH SchemeData. Assuming support for: " + uuid);
} else {
// No data for this manager's scheme.
return false;
}
}
String schemeType = drmInitData.schemeType;
if (schemeType == null || C.CENC_TYPE_cenc.equals(schemeType)) {
// If there is no scheme information, assume patternless AES-CTR.
return true;
} else if (C.CENC_TYPE_cbc1.equals(schemeType)
|| C.CENC_TYPE_cbcs.equals(schemeType)
|| C.CENC_TYPE_cens.equals(schemeType)) {
// API support for AES-CBC and pattern encryption was added in API 24. However, the
// implementation was not stable until API 25.
return Util.SDK_INT >= 25;
}
// Unknown schemes, assume one of them is supported.
return true;
}
@Override
@Nullable
public DrmSession acquirePlaceholderSession(Looper playbackLooper, int trackType) {
@ -593,6 +561,37 @@ public class DefaultDrmSessionManager implements DrmSessionManager {
// Internal methods.
private boolean canAcquireSession(DrmInitData drmInitData) {
if (offlineLicenseKeySetId != null) {
// An offline license can be restored so a session can always be acquired.
return true;
}
List<SchemeData> schemeDatas = getSchemeDatas(drmInitData, uuid, true);
if (schemeDatas.isEmpty()) {
if (drmInitData.schemeDataCount == 1 && drmInitData.get(0).matches(C.COMMON_PSSH_UUID)) {
// Assume scheme specific data will be added before the session is opened.
Log.w(
TAG, "DrmInitData only contains common PSSH SchemeData. Assuming support for: " + uuid);
} else {
// No data for this manager's scheme.
return false;
}
}
String schemeType = drmInitData.schemeType;
if (schemeType == null || C.CENC_TYPE_cenc.equals(schemeType)) {
// If there is no scheme information, assume patternless AES-CTR.
return true;
} else if (C.CENC_TYPE_cbc1.equals(schemeType)
|| C.CENC_TYPE_cbcs.equals(schemeType)
|| C.CENC_TYPE_cens.equals(schemeType)) {
// API support for AES-CBC and pattern encryption was added in API 24. However, the
// implementation was not stable until API 25.
return Util.SDK_INT >= 25;
}
// Unknown schemes, assume one of them is supported.
return true;
}
private void initPlaybackLooper(Looper playbackLooper) {
if (this.playbackLooper == null) {
this.playbackLooper = playbackLooper;

View File

@ -32,11 +32,6 @@ public interface DrmSessionManager {
DrmSessionManager DUMMY =
new DrmSessionManager() {
@Override
public boolean canAcquireSession(DrmInitData drmInitData) {
return false;
}
@Override
public DrmSession acquireSession(
Looper playbackLooper,
@ -70,16 +65,6 @@ public interface DrmSessionManager {
// Do nothing.
}
/**
* Returns whether the manager is capable of acquiring a session for the given
* {@link DrmInitData}.
*
* @param drmInitData DRM initialization data.
* @return Whether the manager is capable of acquiring a session for the given
* {@link DrmInitData}.
*/
boolean canAcquireSession(DrmInitData drmInitData);
/**
* Returns a {@link DrmSession} that does not execute key requests, with an incremented reference
* count. When the caller no longer needs to use the instance, it must call {@link