Bug 1338924 - Pass duration of sample being decrypted to CDM. r=gerald
authorChris Pearce <cpearce@mozilla.com>
Tue, 14 Feb 2017 11:29:32 +1300
changeset 371801 70bc7d4e85125cad0bf02085a004e3939871f2e0
parent 371800 a19ac5da60828cdcf374e6798dc7e07b8b4c1b7d
child 371802 543667d3e5265c31fd253191fb973bd079b9a3b7
push id10863
push userjlorenzo@mozilla.com
push dateMon, 06 Mar 2017 23:02:23 +0000
treeherdermozilla-aurora@0931190cd725 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersgerald
bugs1338924
milestone54.0a1
Bug 1338924 - Pass duration of sample being decrypted to CDM. r=gerald MozReview-Commit-ID: 3UujuYPpfJi
dom/media/gmp-plugin/gmp-test-decryptor.h
dom/media/gmp/GMPCDMProxy.cpp
dom/media/gmp/GMPDecryptorChild.cpp
dom/media/gmp/GMPDecryptorChild.h
dom/media/gmp/GMPDecryptorParent.cpp
dom/media/gmp/GMPDecryptorParent.h
dom/media/gmp/GMPDecryptorProxy.h
dom/media/gmp/PGMPDecryptor.ipdl
dom/media/gmp/gmp-api/gmp-decryption.h
dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
dom/media/gmp/widevine-adapter/WidevineDecryptor.h
--- a/dom/media/gmp-plugin/gmp-test-decryptor.h
+++ b/dom/media/gmp-plugin/gmp-test-decryptor.h
@@ -58,17 +58,18 @@ public:
 
   void SetServerCertificate(uint32_t aPromiseId,
                             const uint8_t* aServerCert,
                             uint32_t aServerCertSize) override
   {
   }
 
   void Decrypt(GMPBuffer* aBuffer,
-               GMPEncryptedBufferMetadata* aMetadata) override
+               GMPEncryptedBufferMetadata* aMetadata,
+               uint64_t aDurationUses) override
   {
   }
 
   void DecryptingComplete() override;
 
   static void Message(const std::string& aMessage);
 
 private:
--- a/dom/media/gmp/GMPCDMProxy.cpp
+++ b/dom/media/gmp/GMPCDMProxy.cpp
@@ -707,17 +707,17 @@ GMPCDMProxy::gmp_Decrypt(RefPtr<DecryptJ
   if (!mCDM) {
     aJob->PostResult(AbortedErr);
     return;
   }
 
   aJob->mId = ++mDecryptionJobCount;
   nsTArray<uint8_t> data;
   data.AppendElements(aJob->mSample->Data(), aJob->mSample->Size());
-  mCDM->Decrypt(aJob->mId, aJob->mSample->mCrypto, data);
+  mCDM->Decrypt(aJob->mId, aJob->mSample->mCrypto, data, aJob->mSample->mDuration);
   mDecryptionJobs.AppendElement(aJob.forget());
 }
 
 void
 GMPCDMProxy::gmp_Decrypted(uint32_t aId,
                            DecryptStatus aResult,
                            const nsTArray<uint8_t>& aDecryptedData)
 {
--- a/dom/media/gmp/GMPDecryptorChild.cpp
+++ b/dom/media/gmp/GMPDecryptorChild.cpp
@@ -327,31 +327,32 @@ GMPDecryptorChild::RecvSetServerCertific
                                  aServerCert.Length());
 
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GMPDecryptorChild::RecvDecrypt(const uint32_t& aId,
                                InfallibleTArray<uint8_t>&& aBuffer,
-                               const GMPDecryptionData& aMetadata)
+                               const GMPDecryptionData& aMetadata,
+                               const uint64_t& aDurationUsecs)
 {
   if (!mSession) {
     return IPC_FAIL_NO_REASON(this);
   }
 
   // Note: the GMPBufferImpl created here is deleted when the GMP passes
   // it back in the Decrypted() callback above.
   GMPBufferImpl* buffer = new GMPBufferImpl(aId, aBuffer);
 
   // |metadata| lifetime is managed by |buffer|.
   GMPEncryptedBufferDataImpl* metadata = new GMPEncryptedBufferDataImpl(aMetadata);
   buffer->SetMetadata(metadata);
 
-  mSession->Decrypt(buffer, metadata);
+  mSession->Decrypt(buffer, metadata, aDurationUsecs);
   return IPC_OK();
 }
 
 mozilla::ipc::IPCResult
 GMPDecryptorChild::RecvDecryptingComplete()
 {
   // Reset |mSession| before calling DecryptingComplete(). We should not send
   // any IPC messages during tear-down.
--- a/dom/media/gmp/GMPDecryptorChild.h
+++ b/dom/media/gmp/GMPDecryptorChild.h
@@ -98,17 +98,18 @@ private:
   mozilla::ipc::IPCResult RecvCloseSession(const uint32_t& aPromiseId,
                                            const nsCString& aSessionId) override;
 
   mozilla::ipc::IPCResult RecvRemoveSession(const uint32_t& aPromiseId,
                                             const nsCString& aSessionId) override;
 
   mozilla::ipc::IPCResult RecvDecrypt(const uint32_t& aId,
                                       InfallibleTArray<uint8_t>&& aBuffer,
-                                      const GMPDecryptionData& aMetadata) override;
+                                      const GMPDecryptionData& aMetadata,
+                                      const uint64_t& aDurationUsecs) override;
 
   // Resolve/reject promise on completion.
   mozilla::ipc::IPCResult RecvSetServerCertificate(const uint32_t& aPromiseId,
                                                    InfallibleTArray<uint8_t>&& aServerCert) override;
 
   mozilla::ipc::IPCResult RecvDecryptingComplete() override;
 
   template <typename MethodType, typename... ParamType>
--- a/dom/media/gmp/GMPDecryptorParent.cpp
+++ b/dom/media/gmp/GMPDecryptorParent.cpp
@@ -167,17 +167,18 @@ GMPDecryptorParent::SetServerCertificate
   // Caller should ensure parameters passed in from JS are valid.
   MOZ_ASSERT(!aServerCert.IsEmpty());
   Unused << SendSetServerCertificate(aPromiseId, aServerCert);
 }
 
 void
 GMPDecryptorParent::Decrypt(uint32_t aId,
                             const CryptoSample& aCrypto,
-                            const nsTArray<uint8_t>& aBuffer)
+                            const nsTArray<uint8_t>& aBuffer,
+                            uint64_t aDurationUsecs)
 {
   LOGV(("GMPDecryptorParent[%p]::Decrypt(id=%d)", this, aId));
 
   if (!mIsOpen) {
     NS_WARNING("Trying to use a dead GMP decrypter!");
     return;
   }
 
@@ -186,20 +187,20 @@ GMPDecryptorParent::Decrypt(uint32_t aId
 
   if (aCrypto.mValid) {
     GMPDecryptionData data(aCrypto.mKeyId,
                            aCrypto.mIV,
                            aCrypto.mPlainSizes,
                            aCrypto.mEncryptedSizes,
                            aCrypto.mSessionIds);
 
-    Unused << SendDecrypt(aId, aBuffer, data);
+    Unused << SendDecrypt(aId, aBuffer, data, aDurationUsecs);
   } else {
     GMPDecryptionData data;
-    Unused << SendDecrypt(aId, aBuffer, data);
+    Unused << SendDecrypt(aId, aBuffer, data, aDurationUsecs);
   }
 }
 
 mozilla::ipc::IPCResult
 GMPDecryptorParent::RecvSetSessionId(const uint32_t& aCreateSessionId,
                                      const nsCString& aSessionId)
 {
   LOGD(("GMPDecryptorParent[%p]::RecvSetSessionId(token=%u, sessionId='%s')",
--- a/dom/media/gmp/GMPDecryptorParent.h
+++ b/dom/media/gmp/GMPDecryptorParent.h
@@ -56,17 +56,18 @@ public:
   void RemoveSession(uint32_t aPromiseId,
                      const nsCString& aSessionId) override;
 
   void SetServerCertificate(uint32_t aPromiseId,
                             const nsTArray<uint8_t>& aServerCert) override;
 
   void Decrypt(uint32_t aId,
                const CryptoSample& aCrypto,
-               const nsTArray<uint8_t>& aBuffer) override;
+               const nsTArray<uint8_t>& aBuffer,
+               uint64_t aDurationUsecs) override;
 
   void Close() override;
 
   void Shutdown();
 
 private:
   ~GMPDecryptorParent();
 
--- a/dom/media/gmp/GMPDecryptorProxy.h
+++ b/dom/media/gmp/GMPDecryptorProxy.h
@@ -50,14 +50,15 @@ public:
   virtual void RemoveSession(uint32_t aPromiseId,
                              const nsCString& aSessionId) = 0;
 
   virtual void SetServerCertificate(uint32_t aPromiseId,
                                     const nsTArray<uint8_t>& aServerCert) = 0;
 
   virtual void Decrypt(uint32_t aId,
                        const mozilla::CryptoSample& aCrypto,
-                       const nsTArray<uint8_t>& aBuffer) = 0;
+                       const nsTArray<uint8_t>& aBuffer,
+                       uint64_t aDurationUsecs) = 0;
 
   virtual void Close() = 0;
 };
 
 #endif // GMPDecryptorProxy_h_
--- a/dom/media/gmp/PGMPDecryptor.ipdl
+++ b/dom/media/gmp/PGMPDecryptor.ipdl
@@ -41,17 +41,18 @@ child:
   async RemoveSession(uint32_t aPromiseId,
                       nsCString aSessionId);
 
   async SetServerCertificate(uint32_t aPromiseId,
                              uint8_t[] aServerCert);
 
   async Decrypt(uint32_t aId,
                 uint8_t[] aBuffer,
-                GMPDecryptionData aMetadata);
+                GMPDecryptionData aMetadata,
+                uint64_t aDurationUsecs);
 
   async DecryptingComplete();
 
 parent:
   async __delete__();
 
   async SetDecryptorId(uint32_t aId);
 
--- a/dom/media/gmp/gmp-api/gmp-decryption.h
+++ b/dom/media/gmp/gmp-api/gmp-decryption.h
@@ -319,17 +319,18 @@ public:
   // 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;
+                       GMPEncryptedBufferMetadata* aMetadata,
+                       uint64_t aDurationUsecs) = 0;
 
   // Called when the decryption operations are complete.
   // Do not call the GMPDecryptorCallback's functions after this is called.
   virtual void DecryptingComplete() = 0;
 
   virtual ~GMPDecryptor() {}
 };
 
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
@@ -193,17 +193,18 @@ public:
 
 private:
   cdm::Buffer* mBuffer;
   int64_t mTimestamp;
 };
 
 void
 WidevineDecryptor::Decrypt(GMPBuffer* aBuffer,
-                           GMPEncryptedBufferMetadata* aMetadata)
+                           GMPEncryptedBufferMetadata* aMetadata,
+                           uint64_t aDurationUsecs)
 {
   if (!mCallback) {
     Log("WidevineDecryptor::Decrypt() this=%p FAIL; !mCallback", this);
     return;
   }
   const GMPEncryptedBufferMetadata* crypto = aMetadata;
   InputBuffer sample;
   nsTArray<SubsampleEntry> subsamples;
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.h
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.h
@@ -59,17 +59,18 @@ public:
                      const char* aSessionId,
                      uint32_t aSessionIdLength) override;
 
   void SetServerCertificate(uint32_t aPromiseId,
                             const uint8_t* aServerCert,
                             uint32_t aServerCertSize) override;
 
   void Decrypt(GMPBuffer* aBuffer,
-               GMPEncryptedBufferMetadata* aMetadata) override;
+               GMPEncryptedBufferMetadata* aMetadata,
+               uint64_t aDurationUsecs) override;
 
   void DecryptingComplete() override;
 
 
   // cdm::Host_8
   cdm::Buffer* Allocate(uint32_t aCapacity) override;
   void SetTimer(int64_t aDelayMs, void* aContext) override;
   cdm::Time GetCurrentWallTime() override;