Backed out changeset 5ec123aec8aa (bug 1341497) for bustage
authorIris Hsiao <ihsiao@mozilla.com>
Wed, 22 Feb 2017 11:49:25 +0800
changeset 373151 7d6717b64c82545afffe44766fba0054937324f9
parent 373150 5ec123aec8aa82af4242226a6dde6f87bae1c027
child 373152 e52cd3f75ebfeacb1bd2a39df6175fa919777f49
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)
bugs1341497
milestone54.0a1
backs out5ec123aec8aa82af4242226a6dde6f87bae1c027
Backed out changeset 5ec123aec8aa (bug 1341497) for bustage
dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
dom/media/gmp/widevine-adapter/WidevineUtils.cpp
dom/media/gmp/widevine-adapter/WidevineUtils.h
dom/media/gmp/widevine-adapter/moz.build
--- a/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineDecryptor.cpp
@@ -4,16 +4,17 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WidevineDecryptor.h"
 
 #include "WidevineAdapter.h"
 #include "WidevineUtils.h"
 #include "WidevineFileIO.h"
 #include "GMPPlatform.h"
+#include <mozilla/SizePrintfMacros.h>
 #include <stdarg.h>
 #include "TimeUnits.h"
 
 using namespace cdm;
 using namespace std;
 
 namespace mozilla {
 
@@ -155,16 +156,53 @@ void
 WidevineDecryptor::SetServerCertificate(uint32_t aPromiseId,
                                         const uint8_t* aServerCert,
                                         uint32_t aServerCertSize)
 {
   CDM_LOG("Decryptor::SetServerCertificate()");
   CDM()->SetServerCertificate(aPromiseId, aServerCert, aServerCertSize);
 }
 
+class WidevineDecryptedBlock : public cdm::DecryptedBlock {
+public:
+
+  WidevineDecryptedBlock()
+    : mBuffer(nullptr)
+    , mTimestamp(0)
+  {
+  }
+
+  ~WidevineDecryptedBlock() override {
+    if (mBuffer) {
+      mBuffer->Destroy();
+      mBuffer = nullptr;
+    }
+  }
+
+  void SetDecryptedBuffer(cdm::Buffer* aBuffer) override {
+    mBuffer = aBuffer;
+  }
+
+  cdm::Buffer* DecryptedBuffer() override {
+    return mBuffer;
+  }
+
+  void SetTimestamp(int64_t aTimestamp) override {
+    mTimestamp = aTimestamp;
+  }
+
+  int64_t Timestamp() const override {
+    return mTimestamp;
+  }
+
+private:
+  cdm::Buffer* mBuffer;
+  int64_t mTimestamp;
+};
+
 cdm::Time
 WidevineDecryptor::ThrottleDecrypt(cdm::Time aWallTime, cdm::Time aSampleDuration)
 {
   const cdm::Time WindowSize = 1.0;
   const cdm::Time MaxThroughput = 2.0;
 
   // Forget decrypts that happened before the start of our window.
   while (!mDecrypts.empty() && mDecrypts.front().mWallTime < aWallTime - WindowSize) {
@@ -284,16 +322,38 @@ WidevineDecryptor::DecryptingComplete()
   // WidevineVideoDecoder, or a runnable), the CDMWrapper destroys
   // the CDM.
   mCDM = nullptr;
   sDecryptors.erase(mInstanceId);
   mCallback = nullptr;
   Release();
 }
 
+class WidevineBuffer : public cdm::Buffer {
+public:
+  explicit WidevineBuffer(size_t aSize) {
+    CDM_LOG("WidevineBuffer(size=%" PRIuSIZE ") created", aSize);
+    mBuffer.SetLength(aSize);
+  }
+  ~WidevineBuffer() override {
+    CDM_LOG("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
+  }
+  void Destroy() override { delete this; }
+  uint32_t Capacity() const override { return mBuffer.Length(); };
+  uint8_t* Data() override { return mBuffer.Elements(); }
+  void SetSize(uint32_t aSize) override { mBuffer.SetLength(aSize); }
+  uint32_t Size() const override { return mBuffer.Length(); }
+
+private:
+  WidevineBuffer(const WidevineBuffer&);
+  void operator=(const WidevineBuffer&);
+
+  nsTArray<uint8_t> mBuffer;
+};
+
 Buffer*
 WidevineDecryptor::Allocate(uint32_t aCapacity)
 {
   CDM_LOG("Decryptor::Allocate(capacity=%u)", aCapacity);
   return new WidevineBuffer(aCapacity);
 }
 
 class TimerTask : public GMPTask {
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.cpp
@@ -1,16 +1,15 @@
 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "WidevineUtils.h"
 #include "WidevineDecryptor.h"
-#include <mozilla/SizePrintfMacros.h>
 
 #include "gmp-api/gmp-errors.h"
 #include <stdarg.h>
 #include <stdio.h>
 
 namespace mozilla {
 
 namespace detail {
@@ -72,95 +71,9 @@ CDMWrapper::CDMWrapper(cdm::ContentDecry
 
 CDMWrapper::~CDMWrapper()
 {
   CDM_LOG("CDMWrapper destroying CDM=%p", mCDM);
   mCDM->Destroy();
   mCDM = nullptr;
 }
 
-WidevineBuffer::WidevineBuffer(size_t aSize)
-{
-  CDM_LOG("WidevineBuffer(size=%" PRIuSIZE ") created", aSize);
-  mBuffer.SetLength(aSize);
-}
-
-WidevineBuffer::~WidevineBuffer()
-{
-  CDM_LOG("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
-}
-
-void
-WidevineBuffer::Destroy()
-{
-  delete this;
-}
-
-uint32_t
-WidevineBuffer::Capacity() const
-{
-  return mBuffer.Length();
-}
-
-uint8_t*
-WidevineBuffer::Data()
-{
-  return mBuffer.Elements();
-}
-
-void
-WidevineBuffer::SetSize(uint32_t aSize)
-{
-  mBuffer.SetLength(aSize);
-}
-
-uint32_t
-WidevineBuffer::Size() const
-{
-  return mBuffer.Length();
-}
-
-nsTArray<uint8_t>
-WidevineBuffer::ExtractBuffer() {
-  nsTArray<uint8_t> out;
-  out.SwapElements(mBuffer);
-  return out;
-}
-
-WidevineDecryptedBlock::WidevineDecryptedBlock()
-  : mBuffer(nullptr)
-  , mTimestamp(0)
-{
-}
-
-WidevineDecryptedBlock::~WidevineDecryptedBlock()
-{
-  if (mBuffer) {
-    mBuffer->Destroy();
-    mBuffer = nullptr;
-  }
-}
-
-void
-WidevineDecryptedBlock::SetDecryptedBuffer(cdm::Buffer* aBuffer)
-{
-  mBuffer = aBuffer;
-}
-
-cdm::Buffer*
-WidevineDecryptedBlock::DecryptedBuffer()
-{
-  return mBuffer;
-}
-
-void
-WidevineDecryptedBlock::SetTimestamp(int64_t aTimestamp)
-{
-  mTimestamp = aTimestamp;
-}
-
-int64_t
-WidevineDecryptedBlock::Timestamp() const
-{
-  return mTimestamp;
-}
-
 } // namespace mozilla
--- a/dom/media/gmp/widevine-adapter/WidevineUtils.h
+++ b/dom/media/gmp/widevine-adapter/WidevineUtils.h
@@ -56,48 +56,11 @@ private:
 
 void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
                      int64_t aTimestamp,
                      const uint8_t* aData,
                      size_t aDataSize,
                      cdm::InputBuffer &aInputBuffer,
                      nsTArray<cdm::SubsampleEntry> &aSubsamples);
 
-class WidevineBuffer : public cdm::Buffer
-{
-public:
-  explicit WidevineBuffer(size_t aSize);
-  ~WidevineBuffer() override;
-  void Destroy() override;
-  uint32_t Capacity() const override;
-  uint8_t* Data() override;
-  void SetSize(uint32_t aSize) override;
-  uint32_t Size() const override;
-
-  // Moves contents of buffer out into temporary.
-  // Note: This empties the buffer.
-  nsTArray<uint8_t> ExtractBuffer();
-
-private:
-  nsTArray<uint8_t> mBuffer;
-  WidevineBuffer(const WidevineBuffer&);
-  void operator=(const WidevineBuffer&);
-};
-
-class WidevineDecryptedBlock : public cdm::DecryptedBlock
-{
-public:
-
-  WidevineDecryptedBlock();
-  ~WidevineDecryptedBlock() override;
-  void SetDecryptedBuffer(cdm::Buffer* aBuffer) override;
-  cdm::Buffer* DecryptedBuffer() override;
-  void SetTimestamp(int64_t aTimestamp) override;
-  int64_t Timestamp() const override;
-
-private:
-  cdm::Buffer* mBuffer;
-  int64_t mTimestamp;
-};
-
 } // namespace mozilla
 
 #endif // WidevineUtils_h_
--- a/dom/media/gmp/widevine-adapter/moz.build
+++ b/dom/media/gmp/widevine-adapter/moz.build
@@ -9,21 +9,16 @@ SOURCES += [
     'WidevineDecryptor.cpp',
     'WidevineDummyDecoder.cpp',
     'WidevineFileIO.cpp',
     'WidevineUtils.cpp',
     'WidevineVideoDecoder.cpp',
     'WidevineVideoFrame.cpp',
 ]
 
-EXPORTS += [
-    'WidevineDecryptor.h',
-    'WidevineUtils.h'
-]
-
 FINAL_LIBRARY = 'xul'
 
 LOCAL_INCLUDES += [
     '/dom/media/gmp',
 ]
 
 if CONFIG['CLANG_CXX']:
     CXXFLAGS += ['-Wno-error=shadow']