Bug 1495053 - p1: support setting server certificate in MediaDrm bridge. r=cpearce
authorJohn Lin <jolin@mozilla.com>
Fri, 07 Dec 2018 14:43:33 +0000
changeset 508824 c51f74f5fcb8
parent 508823 ffb2ef47c536
child 508825 f21136ecba05
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1495053
milestone65.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1495053 - p1: support setting server certificate in MediaDrm bridge. r=cpearce Differential Revision: https://phabricator.services.mozilla.com/D7790
mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java
--- a/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl
+++ b/mobile/android/geckoview/src/main/aidl/org/mozilla/gecko/media/IMediaDrmBridge.aidl
@@ -17,9 +17,11 @@ interface IMediaDrmBridge {
 
     oneway void updateSession(int promiseId,
                               String sessionId,
                               in byte[] response);
 
     oneway void closeSession(int promiseId, String sessionId);
 
     oneway void release();
+
+    void setServerCertificate(in byte[] cert);
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrm.java
@@ -27,9 +27,10 @@ public interface GeckoMediaDrm {
     void createSession(int createSessionToken,
                        int promiseId,
                        String initDataType,
                        byte[] initData);
     void updateSession(int promiseId, String sessionId, byte[] response);
     void closeSession(int promiseId, String sessionId);
     void release();
     MediaCrypto getMediaCrypto();
+    void setServerCertificate(final byte[] cert);
 }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/GeckoMediaDrmBridgeV21.java
@@ -296,16 +296,26 @@ public class GeckoMediaDrmBridgeV21 impl
     }
 
     @Override
     public MediaCrypto getMediaCrypto() {
         if (DEBUG) Log.d(LOGTAG, "getMediaCrypto()");
         return mCrypto;
     }
 
+    @Override
+    public void setServerCertificate(final byte[] cert) {
+        if (DEBUG) Log.d(LOGTAG, "setServerCertificate()");
+        if (mDrm == null) {
+            throw new IllegalStateException("MediaDrm instance doesn't exist !!");
+        }
+        mDrm.setPropertyByteArray("serviceCertificate", cert);
+        return;
+    }
+
     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);
     }
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridge.java
@@ -145,9 +145,20 @@ final class RemoteMediaDrmBridge impleme
     }
 
     @Override
     public synchronized MediaCrypto getMediaCrypto() {
         if (DEBUG) Log.d(LOGTAG, "getMediaCrypto(), should not enter here!");
         assertTrue(false);
         return null;
     }
-}
\ No newline at end of file
+
+    @Override
+    public synchronized void setServerCertificate(final byte[] cert) {
+        try {
+            mRemote.setServerCertificate(cert);
+        } catch (Exception e) {
+            Log.e(LOGTAG, "Got exception while setting server certificate.", e);
+            throw new RuntimeException(e);
+        }
+    }
+}
+
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/RemoteMediaDrmBridgeStub.java
@@ -238,9 +238,19 @@ final class RemoteMediaDrmBridgeStub ext
         if (mBridge != null) {
             mBridge.release();
             mBridge = null;
         }
         mCallbacks.asBinder().unlinkToDeath(this, 0);
         mCallbacks = null;
         mStubId = "";
     }
+
+    @Override
+    public synchronized void setServerCertificate(final byte[] cert) {
+        try {
+            mBridge.setServerCertificate(cert);
+        } catch (IllegalStateException e) {
+            Log.e(LOGTAG, "Failed to setServerCertificate.", e);
+            throw e;
+        }
+    }
 }