Bug 1417297 - Part2 - Convert fake-cdm to use Chromium ContentDecryptionModule_9 interface. r=cpearce
authorJames Cheng <jacheng@mozilla.com>
Thu, 23 Nov 2017 16:51:23 +0800
changeset 393754 f2f0569649dba4c3147d32d130a0377b7e7b2cc8
parent 393753 88b8a5b2f6689fb37183400b8bbf5915406deaef
child 393755 413ed7bee307520b51f402b85ec12af720caa837
push id32982
push userebalazs@mozilla.com
push dateMon, 27 Nov 2017 21:55:57 +0000
treeherdermozilla-central@5441160857a6 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerscpearce
bugs1417297
milestone59.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 1417297 - Part2 - Convert fake-cdm to use Chromium ContentDecryptionModule_9 interface. r=cpearce MozReview-Commit-ID: L0sF2lO3lDX
dom/media/fake-cdm/cdm-fake.cpp
dom/media/fake-cdm/cdm-test-decryptor.cpp
dom/media/fake-cdm/cdm-test-decryptor.h
dom/media/fake-cdm/cdm-test-storage.cpp
dom/media/fake-cdm/cdm-test-storage.h
dom/media/fake-cdm/manifest.json
--- a/dom/media/fake-cdm/cdm-fake.cpp
+++ b/dom/media/fake-cdm/cdm-fake.cpp
@@ -47,21 +47,21 @@ void INITIALIZE_CDM_MODULE() {
 
 CDM_API
 void* CreateCdmInstance(int cdm_interface_version,
                         const char* key_system,
                         uint32_t key_system_size,
                         GetCdmHostFunc get_cdm_host_func,
                         void* user_data)
 {
-  if (cdm_interface_version != cdm::ContentDecryptionModule_8::kVersion) {
-    // Only support CDM version 8 currently.
+  if (cdm_interface_version != cdm::ContentDecryptionModule_9::kVersion) {
+    // Only support CDM version 9 currently.
     return nullptr;
   }
-  cdm::Host_8* host = static_cast<cdm::Host_8*>(
+  cdm::Host_9* host = static_cast<cdm::Host_9*>(
     get_cdm_host_func(cdm_interface_version, user_data));
   return new FakeDecryptor(host);
 }
 
 
 CDM_API
 bool
 VerifyCdmHost_0(const cdm::HostFile* aHostFiles, uint32_t aNumFiles)
--- a/dom/media/fake-cdm/cdm-test-decryptor.cpp
+++ b/dom/media/fake-cdm/cdm-test-decryptor.cpp
@@ -71,35 +71,33 @@ private:
   static void Finish() {
     FakeDecryptor::Message("test-storage complete");
   }
 
   std::mutex mMutex;
   set<string> mTestIDs;
 };
 
-FakeDecryptor::FakeDecryptor(cdm::Host_8* aHost)
+FakeDecryptor::FakeDecryptor(cdm::Host_9* aHost)
   : mHost(aHost)
 {
   MOZ_ASSERT(!sInstance);
   sInstance = this;
 }
 
 void
 FakeDecryptor::Message(const std::string& aMessage)
 {
   MOZ_ASSERT(sInstance);
   const static std::string sid("fake-session-id");
   sInstance->mHost->OnSessionMessage(sid.c_str(),
                                      sid.size(),
                                      cdm::MessageType::kLicenseRequest,
                                      aMessage.c_str(),
-                                     aMessage.size(),
-                                     nullptr,
-                                     0);
+                                     aMessage.size());
 }
 
 std::vector<std::string>
 Tokenize(const std::string& aString)
 {
   std::stringstream strstr(aString);
   std::istream_iterator<std::string> it(strstr), end;
   return std::vector<std::string>(it, end);
--- a/dom/media/fake-cdm/cdm-test-decryptor.h
+++ b/dom/media/fake-cdm/cdm-test-decryptor.h
@@ -5,25 +5,30 @@
 
 #ifndef FAKE_DECRYPTOR_H__
 #define FAKE_DECRYPTOR_H__
 
 #include "content_decryption_module.h"
 #include <string>
 #include "mozilla/Attributes.h"
 
-class FakeDecryptor : public cdm::ContentDecryptionModule_8 {
+class FakeDecryptor : public cdm::ContentDecryptionModule_9 {
 public:
-  explicit FakeDecryptor(cdm::Host_8* aHost);
+  explicit FakeDecryptor(cdm::Host_9* aHost);
 
   void Initialize(bool aAllowDistinctiveIdentifier,
                   bool aAllowPersistentState) override
   {
   }
 
+  void GetStatusForPolicy(uint32_t aPromiseId,
+                          const cdm::Policy& aPolicy) override
+  {
+  }
+
   void SetServerCertificate(uint32_t aPromiseId,
                             const uint8_t* aServerCertificateData,
                             uint32_t aServerCertificateDataSize)
                             override
   {
   }
 
   void CreateSessionAndGenerateRequest(uint32_t aPromiseId,
@@ -110,25 +115,31 @@ public:
   }
 
   void OnQueryOutputProtectionStatus(cdm::QueryResult aResult,
                                      uint32_t aLinkMask,
                                      uint32_t aOutputProtectionMask) override
   {
   }
 
+  void OnStorageId(uint32_t aVersion,
+                   const uint8_t* aStorageId,
+                   uint32_t aStorageIdSize) override
+  {
+  }
+
   void Destroy() override
   {
     delete this;
     sInstance = nullptr;
   }
 
   static void Message(const std::string& aMessage);
 
-  cdm::Host_8* mHost;
+  cdm::Host_9* mHost;
 
   static FakeDecryptor* sInstance;
 
 private:
 
   virtual ~FakeDecryptor() {}
 
   void TestStorage();
--- a/dom/media/fake-cdm/cdm-test-storage.cpp
+++ b/dom/media/fake-cdm/cdm-test-storage.cpp
@@ -41,17 +41,17 @@ public:
   {
   }
 
   void OnWriteComplete(Status aStatus) override
   {
     Done(aStatus);
   }
 
-  void Do(const string& aName, Host_8* aHost)
+  void Do(const string& aName, Host_9* aHost)
   {
     // Initialize the FileIO.
     mFileIO = aHost->CreateFileIO(this);
     mFileIO->Open(aName.c_str(), aName.size());
   }
 
 private:
   void Done(cdm::FileIOClient::Status aStatus)
@@ -77,33 +77,33 @@ private:
 
   FileIO* mFileIO = nullptr;
   function<void()> mOnSuccess;
   function<void()> mOnFailure;
   std::vector<uint8_t> mData;
 };
 
 void
-WriteRecord(Host_8* aHost,
+WriteRecord(Host_9* aHost,
             const std::string& aRecordName,
             const uint8_t* aData,
             uint32_t aNumBytes,
             function<void()>&& aOnSuccess,
             function<void()>&& aOnFailure)
 {
   // client will be delete in WriteRecordClient::Done
   WriteRecordClient* client = new WriteRecordClient(move(aOnSuccess),
                                                     move(aOnFailure),
                                                     aData,
                                                     aNumBytes);
   client->Do(aRecordName, aHost);
 }
 
 void
-WriteRecord(Host_8* aHost,
+WriteRecord(Host_9* aHost,
             const std::string& aRecordName,
             const std::string& aData,
             function<void()> &&aOnSuccess,
             function<void()>&& aOnFailure)
 {
   return WriteRecord(aHost,
                      aRecordName,
                      (const uint8_t*)aData.c_str(),
@@ -136,17 +136,17 @@ public:
   {
     Done(aStatus, aData, aDataSize);
   }
 
   void OnWriteComplete(Status aStatus) override
   {
   }
 
-  void Do(const string& aName, Host_8* aHost)
+  void Do(const string& aName, Host_9* aHost)
   {
     mFileIO = aHost->CreateFileIO(this);
     mFileIO->Open(aName.c_str(), aName.size());
   }
 
 private:
   void Done(cdm::FileIOClient::Status aStatus,
             const uint8_t* aData,
@@ -171,17 +171,17 @@ private:
     delete this;
   }
 
   FileIO* mFileIO = nullptr;
   function<void(bool, const uint8_t*, uint32_t)> mOnReadComplete;
 };
 
 void
-ReadRecord(Host_8* aHost,
+ReadRecord(Host_9* aHost,
            const std::string& aRecordName,
            function<void(bool, const uint8_t*, uint32_t)>&& aOnReadComplete)
 {
   // client will be delete in ReadRecordClient::Done
   ReadRecordClient* client = new ReadRecordClient(move(aOnReadComplete));
   client->Do(aRecordName, aHost);
 }
 
@@ -203,17 +203,17 @@ public:
                       uint32_t aDataSize) override
   {
   }
 
   void OnWriteComplete(Status aStatus) override
   {
   }
 
-  void Do(const string& aName, Host_8* aHost)
+  void Do(const string& aName, Host_9* aHost)
   {
     // Initialize the FileIO.
     mFileIO = aHost->CreateFileIO(this);
     mFileIO->Open(aName.c_str(), aName.size());
   }
 
 private:
   void Done(cdm::FileIOClient::Status aStatus)
@@ -237,16 +237,16 @@ private:
     delete this;
   }
 
   FileIO* mFileIO = nullptr;
   function<void(bool)> mOpenComplete;;
 };
 
 void
-OpenRecord(Host_8* aHost,
+OpenRecord(Host_9* aHost,
            const std::string& aRecordName,
            function<void(bool)>&& aOpenComplete)
 {
   // client will be delete in OpenRecordClient::Done
   OpenRecordClient* client = new OpenRecordClient(move(aOpenComplete));
   client->Do(aRecordName, aHost);
 }
--- a/dom/media/fake-cdm/cdm-test-storage.h
+++ b/dom/media/fake-cdm/cdm-test-storage.h
@@ -20,35 +20,35 @@
 class ReadContinuation {
 public:
   virtual ~ReadContinuation() {}
   virtual void operator()(bool aSuccess,
                           const uint8_t* aData,
                           uint32_t aDataSize) = 0;
 };
 
-void WriteRecord(cdm::Host_8* aHost,
+void WriteRecord(cdm::Host_9* aHost,
                  const std::string& aRecordName,
                  const std::string& aData,
                  std::function<void()>&& aOnSuccess,
                  std::function<void()>&& aOnFailure);
 
-void WriteRecord(cdm::Host_8* aHost,
+void WriteRecord(cdm::Host_9* aHost,
                  const std::string& aRecordName,
                  const uint8_t* aData,
                  uint32_t aNumBytes,
                  std::function<void()>&& aOnSuccess,
                  std::function<void()>&& aOnFailure);
 
-void ReadRecord(cdm::Host_8* aHost,
+void ReadRecord(cdm::Host_9* aHost,
                 const std::string& aRecordName,
                 std::function<void(bool, const uint8_t*, uint32_t)>&& aOnReadComplete);
 
 class OpenContinuation {
 public:
   virtual ~OpenContinuation() {}
   virtual void operator()(bool aSuccess) = 0;
 };
 
-void OpenRecord(cdm::Host_8* aHost,
+void OpenRecord(cdm::Host_9* aHost,
                 const std::string& aRecordName,
                 std::function<void(bool)>&& aOpenComplete);
 #endif // TEST_CDM_STORAGE_H__
--- a/dom/media/fake-cdm/manifest.json
+++ b/dom/media/fake-cdm/manifest.json
@@ -1,9 +1,9 @@
 {
     "name": "fake",
     "description": "Fake CDM Plugin",
     "version": "1",
     "x-cdm-module-versions": "4",
-    "x-cdm-interface-versions": "8",
-    "x-cdm-host-versions": "8",
+    "x-cdm-interface-versions": "9",
+    "x-cdm-host-versions": "9",
     "x-cdm-codecs": ""
 }
\ No newline at end of file