Skip to content

Commit

Permalink
Fix mapping CLEARKEY_UUID to COMMON_PSSH_UUID
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ojw28 committed Sep 6, 2017
1 parent 53343c3 commit ce25b9b
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private DrmInitData(boolean cloneSchemeDatas, SchemeData... schemeDatas) {
if (cloneSchemeDatas) {
schemeDatas = schemeDatas.clone();
}
// Sorting ensures that universal scheme data(i.e. data that applies to all schemes) is matched
// Sorting ensures that universal scheme data (i.e. data that applies to all schemes) is matched
// last. It's also required by the equals and hashcode implementations.
Arrays.sort(schemeDatas, this);
// Check for no duplicates.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
import android.media.ResourceBusyException;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;

/**
* Used to obtain keys for decrypting protected media streams. See {@link android.media.MediaDrm}.
Expand Down Expand Up @@ -137,11 +136,10 @@ byte[] provideKeyResponse(byte[] scope, byte[] response)
/**
* @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.
* @return An object extends {@link ExoMediaCrypto}, using opaque crypto scheme specific data.
* @throws MediaCryptoException
*/
T createMediaCrypto(UUID uuid, byte[] initData) throws MediaCryptoException;
T createMediaCrypto(byte[] initData) throws MediaCryptoException;

}
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@
@TargetApi(18)
public final class FrameworkMediaDrm implements ExoMediaDrm<FrameworkMediaCrypto> {

private final UUID uuid;
private final MediaDrm mediaDrm;

/**
Expand All @@ -59,10 +60,9 @@ public static FrameworkMediaDrm newInstance(UUID uuid) throws UnsupportedDrmExce
private FrameworkMediaDrm(UUID uuid) throws UnsupportedSchemeException {
Assertions.checkNotNull(uuid);
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.
uuid = C.COMMON_PSSH_UUID;
}
// ClearKey had to be accessed using the Common PSSH UUID prior to API level 27.
uuid = Util.SDK_INT < 27 && C.CLEARKEY_UUID.equals(uuid) ? C.COMMON_PSSH_UUID : uuid;
this.uuid = uuid;
this.mediaDrm = new MediaDrm(uuid);
}

Expand Down Expand Up @@ -169,8 +169,7 @@ public void setPropertyByteArray(String propertyName, byte[] value) {
}

@Override
public FrameworkMediaCrypto createMediaCrypto(UUID uuid, byte[] initData)
throws MediaCryptoException {
public FrameworkMediaCrypto createMediaCrypto(byte[] initData) throws MediaCryptoException {
// 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].
boolean forceAllowInsecureDecoderComponents = Util.SDK_INT < 21
Expand Down

0 comments on commit ce25b9b

Please sign in to comment.