Bug 1495053 - p2: add setServerCertificate() to Java/JNI proxy classes. r=cpearce
authorJohn Lin <jolin@mozilla.com>
Fri, 07 Dec 2018 14:44:10 +0000
changeset 508825 f21136ecba05
parent 508824 c51f74f5fcb8
child 508826 8442297c6818
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 - p2: add setServerCertificate() to Java/JNI proxy classes. r=cpearce Differential Revision: https://phabricator.services.mozilla.com/D7791
dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
dom/media/eme/mediadrm/MediaDrmProxySupport.h
mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java
--- a/dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
+++ b/dom/media/eme/mediadrm/MediaDrmProxySupport.cpp
@@ -256,9 +256,16 @@ void MediaDrmProxySupport::Shutdown() {
 
   if (mDestroyed) {
     return;
   }
   mBridgeProxy->Destroy();
   mDestroyed = true;
 }
 
+bool MediaDrmProxySupport::SetServerCertificate(
+    const nsTArray<uint8_t>& aCert) {
+  jni::ByteArray::LocalRef cert = jni::ByteArray::New(
+      reinterpret_cast<const int8_t*>(aCert.Elements()), aCert.Length());
+  return mBridgeProxy->SetServerCertificate(cert);
+}
+
 }  // namespace mozilla
--- a/dom/media/eme/mediadrm/MediaDrmProxySupport.h
+++ b/dom/media/eme/mediadrm/MediaDrmProxySupport.h
@@ -46,16 +46,18 @@ class MediaDrmProxySupport final {
                      const nsTArray<uint8_t>& aResponse);
 
   void CloseSession(uint32_t aPromiseId, const nsCString& aSessionId);
 
   void Shutdown();
 
   const nsString& GetMediaDrmStubId() const { return mMediaDrmStubId; }
 
+  bool SetServerCertificate(const nsTArray<uint8_t>& aCert);
+
  private:
   const nsString mKeySystem;
   java::MediaDrmProxy::GlobalRef mBridgeProxy;
   java::MediaDrmProxy::NativeMediaDrmProxyCallbacks::GlobalRef mJavaCallbacks;
   DecryptorProxyCallback* mCallback;
   bool mDestroyed;
   nsString mMediaDrmStubId;
 };
--- a/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java
+++ b/mobile/android/geckoview/src/main/java/org/mozilla/gecko/media/MediaDrmProxy.java
@@ -277,16 +277,26 @@ public final class MediaDrmProxy {
         mImpl.closeSession(promiseId, sessionId);
     }
 
     @WrapForJNI(calledFrom = "gecko")
     private String getStubId() {
         return mDrmStubId;
     }
 
+    @WrapForJNI
+    public boolean setServerCertificate(final byte[] cert) {
+        try {
+            mImpl.setServerCertificate(cert);
+            return true;
+        } catch (RuntimeException e) {
+            return false;
+        }
+    }
+
     // Get corresponding MediaCrypto object by a generated UUID for MediaCodec.
     // Will be called on MediaFormatReader's TaskQueue.
     @WrapForJNI
     public static MediaCrypto getMediaCrypto(String stubId) {
         for (MediaDrmProxy proxy : sProxyList) {
             if (proxy.getStubId().equals(stubId)) {
                 return proxy.getMediaCryptoFromBridge();
             }