LCOV - code coverage report
Current view: top level - dom/media/gmp/widevine-adapter - WidevineUtils.h (source / functions) Hit Total Coverage
Test: output.info Lines: 0 6 0.0 %
Date: 2017-07-14 16:53:18 Functions: 0 9 0.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
       2             : /* This Source Code Form is subject to the terms of the Mozilla Public
       3             :  * License, v. 2.0. If a copy of the MPL was not distributed with this
       4             :  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
       5             : 
       6             : #ifndef WidevineUtils_h_
       7             : #define WidevineUtils_h_
       8             : 
       9             : #include "stddef.h"
      10             : #include "content_decryption_module.h"
      11             : #include "gmp-api/gmp-decryption.h"
      12             : #include "gmp-api/gmp-platform.h"
      13             : #include "nsISupportsImpl.h"
      14             : #include "nsTArray.h"
      15             : #include "mozilla/Logging.h"
      16             : 
      17             : namespace mozilla {
      18             : 
      19             : namespace detail {
      20             : LogModule* GetCDMLog();
      21             : } // namespace detail
      22             : 
      23             : #define CDM_LOG(...) MOZ_LOG(detail::GetCDMLog(), mozilla::LogLevel::Debug, (__VA_ARGS__))
      24             : 
      25             : #define ENSURE_TRUE(condition, rv) { \
      26             :   if (!(condition)) {\
      27             :     CDM_LOG("ENSURE_TRUE FAILED %s:%d", __FILE__, __LINE__); \
      28             :     return rv; \
      29             :   } \
      30             : } \
      31             : 
      32             : #define ENSURE_GMP_SUCCESS(err, rv) { \
      33             :   if (GMP_FAILED(err)) {\
      34             :     CDM_LOG("ENSURE_GMP_SUCCESS FAILED %s:%d", __FILE__, __LINE__); \
      35             :     return rv; \
      36             :     } \
      37             : } \
      38             : 
      39             : GMPErr
      40             : ToGMPErr(cdm::Status aStatus);
      41             : 
      42             : class WidevineDecryptor;
      43             : 
      44             : class CDMWrapper {
      45             : public:
      46           0 :   NS_INLINE_DECL_THREADSAFE_REFCOUNTING(CDMWrapper)
      47             : 
      48             :   explicit CDMWrapper(cdm::ContentDecryptionModule_8* aCDM,
      49             :                       WidevineDecryptor* aDecryptor);
      50           0 :   cdm::ContentDecryptionModule_8* GetCDM() const { return mCDM; }
      51             : private:
      52             :   ~CDMWrapper();
      53             :   cdm::ContentDecryptionModule_8* mCDM;
      54             :   RefPtr<WidevineDecryptor> mDecryptor;
      55             : };
      56             : 
      57             : void InitInputBuffer(const GMPEncryptedBufferMetadata* aCrypto,
      58             :                      int64_t aTimestamp,
      59             :                      const uint8_t* aData,
      60             :                      size_t aDataSize,
      61             :                      cdm::InputBuffer &aInputBuffer,
      62             :                      nsTArray<cdm::SubsampleEntry> &aSubsamples);
      63             : 
      64             : namespace gmp {
      65             : class CDMShmemBuffer;
      66             : }
      67             : class WidevineBuffer;
      68             : 
      69             : // Base class for our cdm::Buffer implementations, so we can tell at runtime
      70             : // whether the buffer is a Shmem or non-Shmem buffer.
      71           0 : class CDMBuffer : public cdm::Buffer
      72             : {
      73             : public:
      74           0 :   virtual WidevineBuffer* AsArrayBuffer() { return nullptr; }
      75           0 :   virtual gmp::CDMShmemBuffer* AsShmemBuffer() { return nullptr; }
      76             : };
      77             : 
      78             : class WidevineBuffer : public CDMBuffer
      79             : {
      80             : public:
      81             :   explicit WidevineBuffer(size_t aSize);
      82             :   ~WidevineBuffer() override;
      83             :   void Destroy() override;
      84             :   uint32_t Capacity() const override;
      85             :   uint8_t* Data() override;
      86             :   void SetSize(uint32_t aSize) override;
      87             :   uint32_t Size() const override;
      88             : 
      89             :   // Moves contents of buffer out into temporary.
      90             :   // Note: This empties the buffer.
      91             :   nsTArray<uint8_t> ExtractBuffer();
      92             : 
      93           0 :   WidevineBuffer* AsArrayBuffer() override { return this; }
      94             : 
      95             : private:
      96             :   nsTArray<uint8_t> mBuffer;
      97             :   WidevineBuffer(const WidevineBuffer&);
      98             :   void operator=(const WidevineBuffer&);
      99             : };
     100             : 
     101             : class WidevineDecryptedBlock : public cdm::DecryptedBlock
     102             : {
     103             : public:
     104             : 
     105             :   WidevineDecryptedBlock();
     106             :   ~WidevineDecryptedBlock() override;
     107             :   void SetDecryptedBuffer(cdm::Buffer* aBuffer) override;
     108             :   cdm::Buffer* DecryptedBuffer() override;
     109             :   void SetTimestamp(int64_t aTimestamp) override;
     110             :   int64_t Timestamp() const override;
     111             : 
     112             : private:
     113             :   cdm::Buffer* mBuffer;
     114             :   int64_t mTimestamp;
     115             : };
     116             : 
     117             : } // namespace mozilla
     118             : 
     119             : #endif // WidevineUtils_h_

Generated by: LCOV version 1.13