Bug 1329543 - Remove obsolete GMPDecryptor7 interface that was only used by Primetime. r=gerald draft
authorChris Pearce <cpearce@mozilla.com>
Mon, 16 Jan 2017 15:12:15 +1300
changeset 462236 e77aed93ddcfc6be26f5e922fc85a3de1d3990bc
parent 462235 b5223a8ee9e056a8a8fc89e65a191a4af24c86f3
child 542326 589ebd37ed0cbb19805b2601cb24e4f0814a62fd
push id41681
push userbmo:cpearce@mozilla.com
push dateMon, 16 Jan 2017 21:45:55 +0000
reviewersgerald
bugs1329543, 1278198
milestone53.0a1
Bug 1329543 - Remove obsolete GMPDecryptor7 interface that was only used by Primetime. r=gerald This basically rolls back aec9905b06fe from bug 1278198. MozReview-Commit-ID: Drho21X6npW
dom/media/gmp-plugin/fake.info
dom/media/gmp-plugin/gmp-fake.cpp
dom/media/gmp-plugin/gmp-test-decryptor.h
dom/media/gmp/GMPContentChild.cpp
dom/media/gmp/GMPParent.cpp
dom/media/gmp/gmp-api/gmp-decryption.h
--- a/dom/media/gmp-plugin/fake.info
+++ b/dom/media/gmp-plugin/fake.info
@@ -1,5 +1,5 @@
 Name: fake
-Description: Fake GMP Plugin, which deliberately uses GMP_API_DECRYPTOR_BACKWARDS_COMPAT for its decryptor.
+Description: Fake GMP Plugin.
 Version: 1.0
-APIs: decode-video[h264:broken], eme-decrypt-v7[fake]
+APIs: decode-video[h264:broken], eme-decrypt-v9[fake]
 Libraries: dxva2.dll
--- a/dom/media/gmp-plugin/gmp-fake.cpp
+++ b/dom/media/gmp-plugin/gmp-fake.cpp
@@ -67,17 +67,17 @@ extern "C" {
   PUBLIC_FUNC GMPErr
   GMPGetAPI (const char* aApiName, void* aHostAPI, void** aPluginApi) {
     if (!strcmp (aApiName, GMP_API_VIDEO_DECODER)) {
       // Note: Deliberately advertise in our .info file that we support
       // video-decode, but we fail the "get" call here to simulate what
       // happens when decoder init fails.
       return GMPGenericErr;
 #if defined(GMP_FAKE_SUPPORT_DECRYPT)
-    } else if (!strcmp (aApiName, GMP_API_DECRYPTOR_BACKWARDS_COMPAT)) {
+    } else if (!strcmp (aApiName, GMP_API_DECRYPTOR)) {
       *aPluginApi = new FakeDecryptor(static_cast<GMPDecryptorHost*> (aHostAPI));
       return GMPNoErr;
     } else if (!strcmp (aApiName, GMP_API_ASYNC_SHUTDOWN)) {
       *aPluginApi = new TestAsyncShutdown(static_cast<GMPAsyncShutdownHost*> (aHostAPI));
       return GMPNoErr;
 #endif
     }
     return GMPGenericErr;
--- a/dom/media/gmp-plugin/gmp-test-decryptor.h
+++ b/dom/media/gmp-plugin/gmp-test-decryptor.h
@@ -6,22 +6,25 @@
 #ifndef FAKE_DECRYPTOR_H__
 #define FAKE_DECRYPTOR_H__
 
 #include "gmp-decryption.h"
 #include "gmp-async-shutdown.h"
 #include <string>
 #include "mozilla/Attributes.h"
 
-class FakeDecryptor : public GMPDecryptor7 {
+class FakeDecryptor : public GMPDecryptor {
 public:
 
   explicit FakeDecryptor(GMPDecryptorHost* aHost);
 
-  void Init(GMPDecryptorCallback* aCallback) override {
+  void Init(GMPDecryptorCallback* aCallback,
+            bool aDistinctiveIdentifierRequired,
+            bool aPersistentStateRequired) override
+  {
     mCallback = aCallback;
   }
 
   void CreateSession(uint32_t aCreateSessionToken,
                      uint32_t aPromiseId,
                      const char* aInitDataType,
                      uint32_t aInitDataTypeSize,
                      const uint8_t* aInitData,
--- a/dom/media/gmp/GMPContentChild.cpp
+++ b/dom/media/gmp/GMPContentChild.cpp
@@ -90,130 +90,29 @@ GMPContentChild::AllocPGMPVideoEncoderCh
 
 bool
 GMPContentChild::DeallocPGMPVideoEncoderChild(PGMPVideoEncoderChild* aActor)
 {
   static_cast<GMPVideoEncoderChild*>(aActor)->Release();
   return true;
 }
 
-// Adapts GMPDecryptor7 to the current GMPDecryptor version.
-class GMPDecryptor7BackwardsCompat : public GMPDecryptor {
-public:
-  explicit GMPDecryptor7BackwardsCompat(GMPDecryptor7* aDecryptorV7)
-    : mDecryptorV7(aDecryptorV7)
-  {
-  }
-
-  void Init(GMPDecryptorCallback* aCallback,
-            bool aDistinctiveIdentifierRequired,
-            bool aPersistentStateRequired) override
-  {
-    // Distinctive identifier and persistent state arguments not present
-    // in v7 interface.
-    mDecryptorV7->Init(aCallback);
-  }
-
-  void CreateSession(uint32_t aCreateSessionToken,
-                     uint32_t aPromiseId,
-                     const char* aInitDataType,
-                     uint32_t aInitDataTypeSize,
-                     const uint8_t* aInitData,
-                     uint32_t aInitDataSize,
-                     GMPSessionType aSessionType) override
-  {
-    mDecryptorV7->CreateSession(aCreateSessionToken,
-                                aPromiseId,
-                                aInitDataType,
-                                aInitDataTypeSize,
-                                aInitData,
-                                aInitDataSize,
-                                aSessionType);
-  }
-
-  void LoadSession(uint32_t aPromiseId,
-                   const char* aSessionId,
-                   uint32_t aSessionIdLength) override
-  {
-    mDecryptorV7->LoadSession(aPromiseId, aSessionId, aSessionIdLength);
-  }
-
-  void UpdateSession(uint32_t aPromiseId,
-                     const char* aSessionId,
-                     uint32_t aSessionIdLength,
-                     const uint8_t* aResponse,
-                     uint32_t aResponseSize) override
-  {
-    mDecryptorV7->UpdateSession(aPromiseId,
-                                aSessionId,
-                                aSessionIdLength,
-                                aResponse,
-                                aResponseSize);
-  }
-
-  void CloseSession(uint32_t aPromiseId,
-                    const char* aSessionId,
-                    uint32_t aSessionIdLength) override
-  {
-    mDecryptorV7->CloseSession(aPromiseId, aSessionId, aSessionIdLength);
-  }
-
-  void RemoveSession(uint32_t aPromiseId,
-                     const char* aSessionId,
-                     uint32_t aSessionIdLength) override
-  {
-    mDecryptorV7->RemoveSession(aPromiseId, aSessionId, aSessionIdLength);
-  }
-
-  void SetServerCertificate(uint32_t aPromiseId,
-                            const uint8_t* aServerCert,
-                            uint32_t aServerCertSize) override
-  {
-    mDecryptorV7->SetServerCertificate(aPromiseId, aServerCert, aServerCertSize);
-  }
-
-  void Decrypt(GMPBuffer* aBuffer,
-               GMPEncryptedBufferMetadata* aMetadata) override
-  {
-    mDecryptorV7->Decrypt(aBuffer, aMetadata);
-  }
-
-  void DecryptingComplete() override
-  {
-    mDecryptorV7->DecryptingComplete();
-    delete this;
-  }
-private:
-  GMPDecryptor7* mDecryptorV7;
-};
-
 mozilla::ipc::IPCResult
 GMPContentChild::RecvPGMPDecryptorConstructor(PGMPDecryptorChild* aActor)
 {
   GMPDecryptorChild* child = static_cast<GMPDecryptorChild*>(aActor);
   GMPDecryptorHost* host = static_cast<GMPDecryptorHost*>(child);
 
   void* ptr = nullptr;
   GMPErr err = mGMPChild->GetAPI(GMP_API_DECRYPTOR, host, &ptr, aActor->Id());
-  GMPDecryptor* decryptor = nullptr;
-  if (GMP_SUCCEEDED(err) && ptr) {
-    decryptor = static_cast<GMPDecryptor*>(ptr);
-  } else if (err != GMPNoErr) {
-    // We Adapt the previous GMPDecryptor version to the current, so that
-    // Gecko thinks it's only talking to the current version. v7 differs
-    // from v9 in its Init() function arguments, and v9 has extra enumeration
-    // members at the end of the key status enumerations.
-    err = mGMPChild->GetAPI(GMP_API_DECRYPTOR_BACKWARDS_COMPAT, host, &ptr);
-    if (err != GMPNoErr || !ptr) {
-      return IPC_FAIL_NO_REASON(this);
-    }
-    decryptor = new GMPDecryptor7BackwardsCompat(static_cast<GMPDecryptor7*>(ptr));
+  if (err != GMPNoErr || !ptr) {
+    NS_WARNING("GMPGetAPI call failed trying to construct decryptor.");
+    return IPC_FAIL_NO_REASON(this);
   }
-
-  child->Init(decryptor);
+  child->Init(static_cast<GMPDecryptor*>(ptr));
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GMPContentChild::RecvPGMPVideoDecoderConstructor(PGMPVideoDecoderChild* aActor,
                                                  const uint32_t& aDecryptorId)
 {
--- a/dom/media/gmp/GMPParent.cpp
+++ b/dom/media/gmp/GMPParent.cpp
@@ -879,22 +879,16 @@ GMPParent::ReadGMPInfoFile(nsIFile* aFil
         nsTArray<nsCString> tagTokens;
         SplitAt(":", ts, tagTokens);
         for (nsCString tag : tagTokens) {
           cap.mAPITags.AppendElement(tag);
         }
       }
     }
 
-    // We support the current GMPDecryptor version, and the previous.
-    // We Adapt the previous to the current in the GMPContentChild.
-    if (cap.mAPIName.EqualsLiteral(GMP_API_DECRYPTOR_BACKWARDS_COMPAT)) {
-      cap.mAPIName.AssignLiteral(GMP_API_DECRYPTOR);
-    }
-
     if (cap.mAPIName.EqualsLiteral(GMP_API_DECRYPTOR)) {
       mCanDecrypt = true;
 
 #if defined(XP_LINUX) && defined(MOZ_GMP_SANDBOX)
       if (!mozilla::SandboxInfo::Get().CanSandboxMedia()) {
         printf_stderr("GMPParent::ReadGMPMetaData: Plugin \"%s\" is an EME CDM"
                       " but this system can't sandbox it; not loading.\n",
                       mDisplayName.get());
--- a/dom/media/gmp/gmp-api/gmp-decryption.h
+++ b/dom/media/gmp/gmp-api/gmp-decryption.h
@@ -229,20 +229,17 @@ public:
 };
 
 enum GMPSessionType {
   kGMPTemporySession = 0,
   kGMPPersistentSession = 1,
   kGMPSessionInvalid = 2 // Must always be last.
 };
 
-// Gecko supports the current GMPDecryptor version, and the obsolete
-// version that the Adobe GMP still uses.
 #define GMP_API_DECRYPTOR "eme-decrypt-v9"
-#define GMP_API_DECRYPTOR_BACKWARDS_COMPAT "eme-decrypt-v7"
 
 // API exposed by plugin library to manage decryption sessions.
 // When the Host requests this by calling GMPGetAPIFunc().
 //
 // API name macro: GMP_API_DECRYPTOR
 // Host API: GMPDecryptorHost
 class GMPDecryptor {
 public:
@@ -344,116 +341,9 @@ public:
 
   // Called when the decryption operations are complete.
   // Do not call the GMPDecryptorCallback's functions after this is called.
   virtual void DecryptingComplete() = 0;
 
   virtual ~GMPDecryptor() {}
 };
 
-// v7 is the latest decryptor version supported by the Adobe GMP.
-//
-// API name macro: GMP_API_DECRYPTOR_BACKWARDS_COMPAT
-// Host API: GMPDecryptorHost
-class GMPDecryptor7 {
-public:
-
-  // Sets the callback to use with the decryptor to return results
-  // to Gecko.
-  virtual void Init(GMPDecryptorCallback* aCallback) = 0;
-
-  // Initiates the creation of a session given |aType| and |aInitData|, and
-  // the generation of a license request message.
-  //
-  // This corresponds to a MediaKeySession.generateRequest() call in JS.
-  //
-  // The GMPDecryptor must do the following, in order, upon this method
-  // being called:
-  //
-  // 1. Generate a sessionId to expose to JS, and call
-  //    GMPDecryptorCallback::SetSessionId(aCreateSessionToken, sessionId...)
-  //    with the sessionId to be exposed to JS/EME on the MediaKeySession
-  //    object on which generateRequest() was called, and then
-  // 2. send any messages to JS/EME required to generate a license request
-  //    given the supplied initData, and then
-  // 3. generate a license request message, and send it to JS/EME, and then
-  // 4. call GMPDecryptorCallback::ResolvePromise().
-  //
-  // Note: GMPDecryptorCallback::SetSessionId(aCreateSessionToken, sessionId, ...)
-  // *must* be called before GMPDecryptorCallback::SendMessage(sessionId, ...)
-  // will work.
-  //
-  // If generating the request fails, reject aPromiseId by calling
-  // GMPDecryptorCallback::RejectPromise().
-  virtual void CreateSession(uint32_t aCreateSessionToken,
-                             uint32_t aPromiseId,
-                             const char* aInitDataType,
-                             uint32_t aInitDataTypeSize,
-                             const uint8_t* aInitData,
-                             uint32_t aInitDataSize,
-                             GMPSessionType aSessionType) = 0;
-
-  // Loads a previously loaded persistent session.
-  //
-  // This corresponds to a MediaKeySession.load() call in JS.
-  //
-  // The GMPDecryptor must do the following, in order, upon this method
-  // being called:
-  //
-  // 1. Send any messages to JS/EME, or read from storage, whatever is
-  //    required to load the session, and then
-  // 2. if there is no session with the given sessionId loadable, call
-  //    ResolveLoadSessionPromise(aPromiseId, false), otherwise
-  // 2. mark the session's keys as usable, and then
-  // 3. update the session's expiration, and then
-  // 4. call GMPDecryptorCallback::ResolveLoadSessionPromise(aPromiseId, true).
-  //
-  // If loading the session fails due to error, reject aPromiseId by calling
-  // GMPDecryptorCallback::RejectPromise().
-  virtual void LoadSession(uint32_t aPromiseId,
-                           const char* aSessionId,
-                           uint32_t aSessionIdLength) = 0;
-
-  // Updates the session with |aResponse|.
-  // This corresponds to a MediaKeySession.update() call in JS.
-  virtual void UpdateSession(uint32_t aPromiseId,
-                             const char* aSessionId,
-                             uint32_t aSessionIdLength,
-                             const uint8_t* aResponse,
-                             uint32_t aResponseSize) = 0;
-
-  // Releases the resources (keys) for the specified session.
-  // This corresponds to a MediaKeySession.close() call in JS.
-  virtual void CloseSession(uint32_t aPromiseId,
-                            const char* aSessionId,
-                            uint32_t aSessionIdLength) = 0;
-
-  // Removes the resources (keys) for the specified session.
-  // This corresponds to a MediaKeySession.remove() call in JS.
-  virtual void RemoveSession(uint32_t aPromiseId,
-                             const char* aSessionId,
-                             uint32_t aSessionIdLength) = 0;
-
-  // Resolve/reject promise on completion.
-  // This corresponds to a MediaKeySession.setServerCertificate() call in JS.
-  virtual void SetServerCertificate(uint32_t aPromiseId,
-                                    const uint8_t* aServerCert,
-                                    uint32_t aServerCertSize) = 0;
-
-  // Asynchronously decrypts aBuffer in place. When the decryption is
-  // complete, GMPDecryptor should write the decrypted data back into the
-  // same GMPBuffer object and return it to Gecko by calling Decrypted(),
-  // with the GMPNoErr successcode. If decryption fails, call Decrypted()
-  // with a failure code, and an error event will fire on the media element.
-  // Note: When Decrypted() is called and aBuffer is passed back, aBuffer
-  // is deleted. Don't forget to call Decrypted(), as otherwise aBuffer's
-  // memory will leak!
-  virtual void Decrypt(GMPBuffer* aBuffer,
-                       GMPEncryptedBufferMetadata* aMetadata) = 0;
-
-  // Called when the decryption operations are complete.
-  // Do not call the GMPDecryptorCallback's functions after this is called.
-  virtual void DecryptingComplete() = 0;
-
-  virtual ~GMPDecryptor7() {}
-};
-
 #endif // GMP_DECRYPTION_h_