tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

WidevineUtils.cpp (1681B)


      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 #include "WidevineUtils.h"
      7 
      8 #include <inttypes.h>
      9 
     10 #include "GMPLog.h"
     11 #include "gmp-api/gmp-errors.h"
     12 
     13 namespace mozilla {
     14 
     15 WidevineBuffer::WidevineBuffer(size_t aSize) {
     16  GMP_LOG_DEBUG("WidevineBuffer(size=%zu) created", aSize);
     17  mBuffer.SetLength(aSize);
     18 }
     19 
     20 WidevineBuffer::~WidevineBuffer() {
     21  GMP_LOG_DEBUG("WidevineBuffer(size=%" PRIu32 ") destroyed", Size());
     22 }
     23 
     24 void WidevineBuffer::Destroy() { delete this; }
     25 
     26 uint32_t WidevineBuffer::Capacity() const { return mBuffer.Length(); }
     27 
     28 uint8_t* WidevineBuffer::Data() { return mBuffer.Elements(); }
     29 
     30 void WidevineBuffer::SetSize(uint32_t aSize) { mBuffer.SetLength(aSize); }
     31 
     32 uint32_t WidevineBuffer::Size() const { return mBuffer.Length(); }
     33 
     34 nsTArray<uint8_t> WidevineBuffer::ExtractBuffer() {
     35  nsTArray<uint8_t> out = std::move(mBuffer);
     36  return out;
     37 }
     38 
     39 WidevineDecryptedBlock::WidevineDecryptedBlock()
     40    : mBuffer(nullptr), mTimestamp(0) {}
     41 
     42 WidevineDecryptedBlock::~WidevineDecryptedBlock() {
     43  if (mBuffer) {
     44    mBuffer->Destroy();
     45    mBuffer = nullptr;
     46  }
     47 }
     48 
     49 void WidevineDecryptedBlock::SetDecryptedBuffer(cdm::Buffer* aBuffer) {
     50  mBuffer = aBuffer;
     51 }
     52 
     53 cdm::Buffer* WidevineDecryptedBlock::DecryptedBuffer() { return mBuffer; }
     54 
     55 void WidevineDecryptedBlock::SetTimestamp(int64_t aTimestamp) {
     56  mTimestamp = aTimestamp;
     57 }
     58 
     59 int64_t WidevineDecryptedBlock::Timestamp() const { return mTimestamp; }
     60 
     61 }  // namespace mozilla