Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(283)

Side by Side Diff: media/base/android/java/src/org/chromium/media/MediaDrmBridge.java

Issue 1903343003: media: Use @MainDex for MediaDrmBridge inner classes (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package org.chromium.media; 5 package org.chromium.media;
6 6
7 import android.annotation.TargetApi; 7 import android.annotation.TargetApi;
8 import android.media.MediaCrypto; 8 import android.media.MediaCrypto;
9 import android.media.MediaDrm; 9 import android.media.MediaDrm;
10 import android.os.Build; 10 import android.os.Build;
11 11
12 import org.chromium.base.Log; 12 import org.chromium.base.Log;
13 import org.chromium.base.annotations.CalledByNative; 13 import org.chromium.base.annotations.CalledByNative;
14 import org.chromium.base.annotations.JNINamespace; 14 import org.chromium.base.annotations.JNINamespace;
15 import org.chromium.base.annotations.MainDex;
15 16
16 import java.nio.ByteBuffer; 17 import java.nio.ByteBuffer;
17 import java.util.ArrayDeque; 18 import java.util.ArrayDeque;
18 import java.util.ArrayList; 19 import java.util.ArrayList;
19 import java.util.Arrays; 20 import java.util.Arrays;
20 import java.util.HashMap; 21 import java.util.HashMap;
21 import java.util.List; 22 import java.util.List;
22 import java.util.UUID; 23 import java.util.UUID;
23 24
24 /** 25 /**
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 private ArrayDeque<PendingCreateSessionData> mPendingCreateSessionDataQueue; 83 private ArrayDeque<PendingCreateSessionData> mPendingCreateSessionDataQueue;
83 84
84 private boolean mResetDeviceCredentialsPending; 85 private boolean mResetDeviceCredentialsPending;
85 86
86 // MediaDrmBridge is waiting for provisioning response from the server. 87 // MediaDrmBridge is waiting for provisioning response from the server.
87 private boolean mProvisioningPending; 88 private boolean mProvisioningPending;
88 89
89 /** 90 /**
90 * An equivalent of MediaDrm.KeyStatus, which is only available on M+. 91 * An equivalent of MediaDrm.KeyStatus, which is only available on M+.
91 */ 92 */
93 @MainDex
92 private static class KeyStatus { 94 private static class KeyStatus {
93 private final byte[] mKeyId; 95 private final byte[] mKeyId;
94 private final int mStatusCode; 96 private final int mStatusCode;
95 97
96 private KeyStatus(byte[] keyId, int statusCode) { 98 private KeyStatus(byte[] keyId, int statusCode) {
97 mKeyId = keyId; 99 mKeyId = keyId;
98 mStatusCode = statusCode; 100 mStatusCode = statusCode;
99 } 101 }
100 102
101 @CalledByNative("KeyStatus") 103 @CalledByNative("KeyStatus")
(...skipping 13 matching lines...) Expand all
115 */ 117 */
116 private static List<KeyStatus> getDummyKeysInfo(int statusCode) { 118 private static List<KeyStatus> getDummyKeysInfo(int statusCode) {
117 List<KeyStatus> keysInfo = new ArrayList<KeyStatus>(); 119 List<KeyStatus> keysInfo = new ArrayList<KeyStatus>();
118 keysInfo.add(new KeyStatus(DUMMY_KEY_ID, statusCode)); 120 keysInfo.add(new KeyStatus(DUMMY_KEY_ID, statusCode));
119 return keysInfo; 121 return keysInfo;
120 } 122 }
121 123
122 /** 124 /**
123 * This class contains data needed to call createSession(). 125 * This class contains data needed to call createSession().
124 */ 126 */
127 @MainDex
125 private static class PendingCreateSessionData { 128 private static class PendingCreateSessionData {
126 private final byte[] mInitData; 129 private final byte[] mInitData;
127 private final String mMimeType; 130 private final String mMimeType;
128 private final HashMap<String, String> mOptionalParameters; 131 private final HashMap<String, String> mOptionalParameters;
129 private final long mPromiseId; 132 private final long mPromiseId;
130 133
131 private PendingCreateSessionData(byte[] initData, String mimeType, 134 private PendingCreateSessionData(byte[] initData, String mimeType,
132 HashMap<String, String> optionalParameters, long promiseId) { 135 HashMap<String, String> optionalParameters, long promiseId) {
133 mInitData = initData; 136 mInitData = initData;
134 mMimeType = mimeType; 137 mMimeType = mimeType;
(...skipping 771 matching lines...) Expand 10 before | Expand all | Expand 10 after
906 nativeOnLegacySessionError(mNativeMediaDrmBridge, sessionId, errorMe ssage); 909 nativeOnLegacySessionError(mNativeMediaDrmBridge, sessionId, errorMe ssage);
907 } 910 }
908 } 911 }
909 912
910 private void onResetDeviceCredentialsCompleted(final boolean success) { 913 private void onResetDeviceCredentialsCompleted(final boolean success) {
911 if (isNativeMediaDrmBridgeValid()) { 914 if (isNativeMediaDrmBridgeValid()) {
912 nativeOnResetDeviceCredentialsCompleted(mNativeMediaDrmBridge, succe ss); 915 nativeOnResetDeviceCredentialsCompleted(mNativeMediaDrmBridge, succe ss);
913 } 916 }
914 } 917 }
915 918
919 @MainDex
916 private class EventListener implements MediaDrm.OnEventListener { 920 private class EventListener implements MediaDrm.OnEventListener {
917 @Override 921 @Override
918 public void onEvent( 922 public void onEvent(
919 MediaDrm mediaDrm, byte[] sessionId, int event, int extra, byte[ ] data) { 923 MediaDrm mediaDrm, byte[] sessionId, int event, int extra, byte[ ] data) {
920 if (sessionId == null) { 924 if (sessionId == null) {
921 Log.e(TAG, "EventListener: Null session."); 925 Log.e(TAG, "EventListener: Null session.");
922 return; 926 return;
923 } 927 }
924 if (!sessionExists(sessionId)) { 928 if (!sessionExists(sessionId)) {
925 Log.e(TAG, "EventListener: Invalid session %s", bytesToHexString (sessionId)); 929 Log.e(TAG, "EventListener: Invalid session %s", bytesToHexString (sessionId));
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
969 assert false; // Should never happen. 973 assert false; // Should never happen.
970 break; 974 break;
971 default: 975 default:
972 Log.e(TAG, "Invalid DRM event " + event); 976 Log.e(TAG, "Invalid DRM event " + event);
973 return; 977 return;
974 } 978 }
975 } 979 }
976 } 980 }
977 981
978 @TargetApi(Build.VERSION_CODES.M) 982 @TargetApi(Build.VERSION_CODES.M)
983 @MainDex
979 private class KeyStatusChangeListener implements MediaDrm.OnKeyStatusChangeL istener { 984 private class KeyStatusChangeListener implements MediaDrm.OnKeyStatusChangeL istener {
980 private List<KeyStatus> getKeysInfo(List<MediaDrm.KeyStatus> keyInformat ion) { 985 private List<KeyStatus> getKeysInfo(List<MediaDrm.KeyStatus> keyInformat ion) {
981 List<KeyStatus> keysInfo = new ArrayList<KeyStatus>(); 986 List<KeyStatus> keysInfo = new ArrayList<KeyStatus>();
982 for (MediaDrm.KeyStatus keyStatus : keyInformation) { 987 for (MediaDrm.KeyStatus keyStatus : keyInformation) {
983 keysInfo.add(new KeyStatus(keyStatus.getKeyId(), keyStatus.getSt atusCode())); 988 keysInfo.add(new KeyStatus(keyStatus.getKeyId(), keyStatus.getSt atusCode()));
984 } 989 }
985 return keysInfo; 990 return keysInfo;
986 } 991 }
987 992
988 @Override 993 @Override
989 public void onKeyStatusChange(MediaDrm md, byte[] sessionId, 994 public void onKeyStatusChange(MediaDrm md, byte[] sessionId,
990 List<MediaDrm.KeyStatus> keyInformation, boolean hasNewUsableKey ) { 995 List<MediaDrm.KeyStatus> keyInformation, boolean hasNewUsableKey ) {
991 Log.d(TAG, "KeysStatusChange: " + bytesToHexString(sessionId) + ", " + hasNewUsableKey); 996 Log.d(TAG, "KeysStatusChange: " + bytesToHexString(sessionId) + ", " + hasNewUsableKey);
992 997
993 onSessionKeysChange(sessionId, getKeysInfo(keyInformation).toArray() , hasNewUsableKey); 998 onSessionKeysChange(sessionId, getKeysInfo(keyInformation).toArray() , hasNewUsableKey);
994 } 999 }
995 } 1000 }
996 1001
997 @TargetApi(Build.VERSION_CODES.M) 1002 @TargetApi(Build.VERSION_CODES.M)
1003 @MainDex
998 private class ExpirationUpdateListener implements MediaDrm.OnExpirationUpdat eListener { 1004 private class ExpirationUpdateListener implements MediaDrm.OnExpirationUpdat eListener {
999 @Override 1005 @Override
1000 public void onExpirationUpdate(MediaDrm md, byte[] sessionId, long expir ationTime) { 1006 public void onExpirationUpdate(MediaDrm md, byte[] sessionId, long expir ationTime) {
1001 Log.d(TAG, "ExpirationUpdate: " + bytesToHexString(sessionId) + ", " + expirationTime); 1007 Log.d(TAG, "ExpirationUpdate: " + bytesToHexString(sessionId) + ", " + expirationTime);
1002 onSessionExpirationUpdate(sessionId, expirationTime); 1008 onSessionExpirationUpdate(sessionId, expirationTime);
1003 } 1009 }
1004 } 1010 }
1005 1011
1006 // Native functions. At the native side, must post the task immediately to 1012 // Native functions. At the native side, must post the task immediately to
1007 // avoid reentrancy issues. 1013 // avoid reentrancy issues.
(...skipping 15 matching lines...) Expand all
1023 private native void nativeOnSessionKeysChange(long nativeMediaDrmBridge, byt e[] sessionId, 1029 private native void nativeOnSessionKeysChange(long nativeMediaDrmBridge, byt e[] sessionId,
1024 Object[] keysInfo, boolean hasAdditionalUsableKey); 1030 Object[] keysInfo, boolean hasAdditionalUsableKey);
1025 private native void nativeOnSessionExpirationUpdate( 1031 private native void nativeOnSessionExpirationUpdate(
1026 long nativeMediaDrmBridge, byte[] sessionId, long expirationTime); 1032 long nativeMediaDrmBridge, byte[] sessionId, long expirationTime);
1027 private native void nativeOnLegacySessionError( 1033 private native void nativeOnLegacySessionError(
1028 long nativeMediaDrmBridge, byte[] sessionId, String errorMessage); 1034 long nativeMediaDrmBridge, byte[] sessionId, String errorMessage);
1029 1035
1030 private native void nativeOnResetDeviceCredentialsCompleted( 1036 private native void nativeOnResetDeviceCredentialsCompleted(
1031 long nativeMediaDrmBridge, boolean success); 1037 long nativeMediaDrmBridge, boolean success);
1032 } 1038 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698