tor-browser

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

cdm-test-decryptor.h (3687B)


      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 FAKE_DECRYPTOR_H__
      7 #define FAKE_DECRYPTOR_H__
      8 
      9 #include <string>
     10 
     11 #include "content_decryption_module.h"
     12 
     13 class FakeDecryptor : public cdm::ContentDecryptionModule_10 {
     14 public:
     15  explicit FakeDecryptor(cdm::Host_11* aHost);
     16 
     17  void Initialize(bool aAllowDistinctiveIdentifier, bool aAllowPersistentState,
     18                  bool aUseHardwareSecureCodecs) override {
     19    mHost->OnInitialized(true);
     20  }
     21 
     22  void GetStatusForPolicy(uint32_t aPromiseId,
     23                          const cdm::Policy& aPolicy) override {}
     24 
     25  void SetServerCertificate(uint32_t aPromiseId,
     26                            const uint8_t* aServerCertificateData,
     27                            uint32_t aServerCertificateDataSize) override {}
     28 
     29  void CreateSessionAndGenerateRequest(uint32_t aPromiseId,
     30                                       cdm::SessionType aSessionType,
     31                                       cdm::InitDataType aInitDataType,
     32                                       const uint8_t* aInitData,
     33                                       uint32_t aInitDataSize) override {}
     34 
     35  void LoadSession(uint32_t aPromiseId, cdm::SessionType aSessionType,
     36                   const char* aSessionId, uint32_t aSessionIdSize) override {}
     37 
     38  void UpdateSession(uint32_t aPromiseId, const char* aSessionId,
     39                     uint32_t aSessionIdSize, const uint8_t* aResponse,
     40                     uint32_t aResponseSize) override;
     41 
     42  void CloseSession(uint32_t aPromiseId, const char* aSessionId,
     43                    uint32_t aSessionIdSize) override {}
     44 
     45  void RemoveSession(uint32_t aPromiseId, const char* aSessionId,
     46                     uint32_t aSessionIdSize) override {}
     47 
     48  void TimerExpired(void* aContext) override {}
     49 
     50  cdm::Status Decrypt(const cdm::InputBuffer_2& aEncryptedBuffer,
     51                      cdm::DecryptedBlock* aDecryptedBuffer) override {
     52    return cdm::Status::kDecodeError;
     53  }
     54 
     55  cdm::Status InitializeAudioDecoder(
     56      const cdm::AudioDecoderConfig_2& aAudioDecoderConfig) override {
     57    return cdm::Status::kDecodeError;
     58  }
     59 
     60  cdm::Status InitializeVideoDecoder(
     61      const cdm::VideoDecoderConfig_2& aVideoDecoderConfig) override {
     62    return cdm::Status::kDecodeError;
     63  }
     64 
     65  void DeinitializeDecoder(cdm::StreamType aDecoderType) override {}
     66 
     67  void ResetDecoder(cdm::StreamType aDecoderType) override {}
     68 
     69  cdm::Status DecryptAndDecodeFrame(const cdm::InputBuffer_2& aEncryptedBuffer,
     70                                    cdm::VideoFrame* aVideoFrame) override {
     71    return cdm::Status::kDecodeError;
     72  }
     73 
     74  cdm::Status DecryptAndDecodeSamples(
     75      const cdm::InputBuffer_2& aEncryptedBuffer,
     76      cdm::AudioFrames* aAudioFrame) override {
     77    return cdm::Status::kDecodeError;
     78  }
     79 
     80  void OnPlatformChallengeResponse(
     81      const cdm::PlatformChallengeResponse& aResponse) override {}
     82 
     83  void OnQueryOutputProtectionStatus(cdm::QueryResult aResult,
     84                                     uint32_t aLinkMask,
     85                                     uint32_t aOutputProtectionMask) override {}
     86 
     87  void OnStorageId(uint32_t aVersion, const uint8_t* aStorageId,
     88                   uint32_t aStorageIdSize) override {}
     89 
     90  void Destroy() override {
     91    delete this;
     92    sInstance = nullptr;
     93  }
     94 
     95  static void Message(const std::string& aMessage);
     96 
     97  cdm::Host_11* mHost;
     98 
     99  static FakeDecryptor* sInstance;
    100 
    101 private:
    102  virtual ~FakeDecryptor() = default;
    103 
    104  void TestStorage();
    105 };
    106 
    107 #endif