Fix mapping CLEARKEY_UUID to COMMON_PSSH_UUID

This mapping when we call into platform components also needs
to be applied when creating the MediaCrypto instance. The fix
is to stop propagating the UUID through all the createMediaCrypto
methods. This is unnecessary, since the eventual target already
knows its own UUID!

Issue: #3138

-------------
Created by MOE: https://github.com/google/moe
MOE_MIGRATED_REVID=166843372
This commit is contained in:
olly 2017-08-29 07:19:48 -07:00 committed by Oliver Woodman
parent 3e76227006
commit f44e30c754
4 changed files with 8 additions and 11 deletions

View File

@ -226,7 +226,7 @@ import java.util.UUID;
try { try {
sessionId = mediaDrm.openSession(); sessionId = mediaDrm.openSession();
mediaCrypto = mediaDrm.createMediaCrypto(uuid, sessionId); mediaCrypto = mediaDrm.createMediaCrypto(sessionId);
state = STATE_OPENED; state = STATE_OPENED;
return true; return true;
} catch (NotProvisionedException e) { } catch (NotProvisionedException e) {

View File

@ -22,7 +22,6 @@ import android.media.NotProvisionedException;
import android.media.ResourceBusyException; import android.media.ResourceBusyException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.UUID;
/** /**
* Used to obtain keys for decrypting protected media streams. See {@link android.media.MediaDrm}. * Used to obtain keys for decrypting protected media streams. See {@link android.media.MediaDrm}.
@ -137,11 +136,10 @@ public interface ExoMediaDrm<T extends ExoMediaCrypto> {
/** /**
* @see android.media.MediaCrypto#MediaCrypto(UUID, byte[]) * @see android.media.MediaCrypto#MediaCrypto(UUID, byte[])
* *
* @param uuid The UUID of the crypto scheme.
* @param initData Opaque initialization data specific to the crypto scheme. * @param initData Opaque initialization data specific to the crypto scheme.
* @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data. * @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
* @throws MediaCryptoException * @throws MediaCryptoException
*/ */
T createMediaCrypto(UUID uuid, byte[] initData) throws MediaCryptoException; T createMediaCrypto(byte[] initData) throws MediaCryptoException;
} }

View File

@ -37,6 +37,7 @@ import java.util.UUID;
@TargetApi(18) @TargetApi(18)
public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto> { public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto> {
private final UUID uuid;
private final MediaDrm mediaDrm; private final MediaDrm mediaDrm;
/** /**
@ -59,10 +60,9 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException { private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException {
Assertions.checkNotNull(uuid); Assertions.checkNotNull(uuid);
Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead"); Assertions.checkArgument(!C.COMMON_PSSH_UUID.equals(uuid), "Use C.CLEARKEY_UUID instead");
if (Util.SDK_INT < 27 && C.CLEARKEY_UUID.equals(uuid)) {
// ClearKey had to be accessed using the Common PSSH UUID prior to API level 27. // ClearKey had to be accessed using the Common PSSH UUID prior to API level 27.
uuid = C.COMMON_PSSH_UUID; uuid = Util.SDK_INT < 27 && C.CLEARKEY_UUID.equals(uuid) ? C.COMMON_PSSH_UUID : uuid;
} this.uuid = uuid;
this.mediaDrm = new MediaDrm(uuid); this.mediaDrm = new MediaDrm(uuid);
} }
@ -169,8 +169,7 @@ public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto
} }
@Override @Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData) public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
throws MediaCryptoException {
// Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still // Work around a bug prior to Lollipop where L1 Widevine forced into L3 mode would still
// indicate that it required secure video decoders [Internal ref: b/11428937]. // indicate that it required secure video decoders [Internal ref: b/11428937].
boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21 boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21