Bug 1320271 - Some tweaks related to MediaDrmBridge. r=jchen

MozReview-Commit-ID: Nt5FEmd1p6

--HG--
extra : rebase_source : fc06dc57f57159aa6224ff0d454d1bf85752061e
This commit is contained in:
James Cheng 2016-11-25 16:28:27 +08:00
parent 65009646f8
commit 9c50104423
4 changed files with 18 additions and 43 deletions

View File

@ -212,11 +212,7 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
Log.d(LOGTAG, "InfoMap : key(" + strKey + ")/value(" + strValue + ")");
}
}
SessionKeyInfo[] keyInfos = new SessionKeyInfo[1];
keyInfos[0] = new SessionKeyInfo(DUMMY_KEY_ID,
MediaDrm.KeyStatus.STATUS_USABLE);
onSessionBatchedKeyChanged(session.array(), keyInfos);
if (DEBUG) Log.d(LOGTAG, "Key successfully added for session " + sessionId);
HandleKeyStatusChangeByDummyKey(sessionId);
onSessionUpdated(promiseId, session.array());
return;
} catch (final NotProvisionedException | DeniedByServerException | IllegalStateException e) {
@ -285,6 +281,15 @@ public class GeckoMediaDrmBridgeV21 implements GeckoMediaDrm {
return mCrypto;
}
protected void HandleKeyStatusChangeByDummyKey(String sessionId)
{
SessionKeyInfo[] keyInfos = new SessionKeyInfo[1];
keyInfos[0] = new SessionKeyInfo(DUMMY_KEY_ID,
MediaDrm.KeyStatus.STATUS_USABLE);
onSessionBatchedKeyChanged(sessionId.getBytes(), keyInfos);
if (DEBUG) Log.d(LOGTAG, "Key successfully added for session " + sessionId);
}
protected void onSessionCreated(int createSessionToken,
int promiseId,
byte[] sessionId,

View File

@ -16,6 +16,7 @@ import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.List;
@TargetApi(M)
public class GeckoMediaDrmBridgeV23 extends GeckoMediaDrmBridgeV21 {
private static final boolean DEBUG = false;
@ -25,7 +26,6 @@ public class GeckoMediaDrmBridgeV23 extends GeckoMediaDrmBridgeV21 {
mDrm.setOnKeyStatusChangeListener(new KeyStatusChangeListener(), null);
}
@TargetApi(M)
private class KeyStatusChangeListener implements MediaDrm.OnKeyStatusChangeListener {
@Override
public void onKeyStatusChange(MediaDrm mediaDrm,
@ -48,38 +48,9 @@ public class GeckoMediaDrmBridgeV23 extends GeckoMediaDrmBridgeV21 {
}
@Override
public void updateSession(int promiseId,
String sessionId,
byte[] response) {
if (DEBUG) Log.d(LOGTAG, "updateSession(), sessionId = " + sessionId);
if (mDrm == null) {
onRejectPromise(promiseId, "MediaDrm instance doesn't exist !!");
return;
}
ByteBuffer session = ByteBuffer.wrap(sessionId.getBytes());
if (!sessionExists(session)) {
onRejectPromise(promiseId, "Invalid session during updateSession.");
return;
}
try {
final byte [] keySetId = mDrm.provideKeyResponse(session.array(), response);
if (DEBUG) {
HashMap<String, String> infoMap = mDrm.queryKeyStatus(session.array());
for (String strKey : infoMap.keySet()) {
String strValue = infoMap.get(strKey);
Log.d(LOGTAG, "InfoMap : key(" + strKey + ")/value(" + strValue + ")");
}
}
onSessionUpdated(promiseId, session.array());
return;
} catch (final NotProvisionedException | DeniedByServerException | IllegalStateException e) {
if (DEBUG) Log.d(LOGTAG, "Failed to provide key response:", e);
onSessionError(session.array(), "Got exception during updateSession.");
onRejectPromise(promiseId, "Got exception during updateSession.");
}
release();
return;
protected void HandleKeyStatusChangeByDummyKey(String sessionId)
{
// MediaDrm.KeyStatus information listener is supported on M+, there is no need to use
// dummy key id to report key status anymore.
}
}

View File

@ -86,9 +86,9 @@ final class LocalMediaDrmBridge implements GeckoMediaDrm {
LocalMediaDrmBridge(String keySystem) throws Exception {
if (AppConstants.Versions.preLollipop) {
Log.e(LOGTAG, "Pre-Lollipop should never enter here!!");
mBridge = null;
} else if (AppConstants.Versions.feature21Plus &&
AppConstants.Versions.preMarshmallow) {
} else if (AppConstants.Versions.preMarshmallow) {
mBridge = new GeckoMediaDrmBridgeV21(keySystem);
} else {
mBridge = new GeckoMediaDrmBridgeV23(keySystem);

View File

@ -151,8 +151,7 @@ final class RemoteMediaDrmBridgeStub extends IMediaDrmBridge.Stub implements IBi
throw new RemoteException("Error, unsupported version!");
}
try {
if (AppConstants.Versions.feature21Plus &&
AppConstants.Versions.preMarshmallow) {
if (AppConstants.Versions.preMarshmallow) {
mBridge = new GeckoMediaDrmBridgeV21(keySystem);
} else {
mBridge = new GeckoMediaDrmBridgeV23(keySystem);