tor-browser

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

MediaDrmProxySupport.h (2095B)


      1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
      2 /* vim: set ts=8 sts=2 et sw=2 tw=80: */
      3 /* This Source Code Form is subject to the terms of the Mozilla Public
      4 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      5 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      6 
      7 #ifndef MediaDrmProxySupport_H
      8 #define MediaDrmProxySupport_H
      9 
     10 #include "mozilla/DecryptorProxyCallback.h"
     11 #include "mozilla/Logging.h"
     12 #include "mozilla/UniquePtr.h"
     13 #include "mozilla/java/MediaDrmProxyWrappers.h"
     14 #include "nsString.h"
     15 
     16 namespace mozilla {
     17 
     18 enum MediaDrmSessionType {
     19  kKeyStreaming = 1,
     20  kKeyOffline = 2,
     21  kKeyRelease = 3,
     22 };
     23 
     24 #ifndef MDRMN_LOG
     25 LogModule* GetMDRMNLog();
     26 #  define MDRMN_LOG(x, ...)                          \
     27    MOZ_LOG(GetMDRMNLog(), mozilla::LogLevel::Debug, \
     28            ("[MediaDrmProxySupport][%s]" x, __FUNCTION__, ##__VA_ARGS__))
     29 #endif
     30 
     31 class MediaDrmCDMCallbackProxy;
     32 
     33 class MediaDrmProxySupport final {
     34 public:
     35  explicit MediaDrmProxySupport(const nsAString& aKeySystem);
     36  ~MediaDrmProxySupport();
     37 
     38  /*
     39   * APIs to act as GMPDecryptorAPI, discarding unnecessary calls.
     40   */
     41  nsresult Init(UniquePtr<MediaDrmCDMCallbackProxy>&& aCallback);
     42 
     43  void CreateSession(uint32_t aCreateSessionToken, uint32_t aPromiseId,
     44                     const nsCString& aInitDataType,
     45                     const nsTArray<uint8_t>& aInitData,
     46                     MediaDrmSessionType aSessionType);
     47 
     48  void UpdateSession(uint32_t aPromiseId, const nsCString& aSessionId,
     49                     const nsTArray<uint8_t>& aResponse);
     50 
     51  void CloseSession(uint32_t aPromiseId, const nsCString& aSessionId);
     52 
     53  void Shutdown();
     54 
     55  const nsString& GetMediaDrmStubId() const { return mMediaDrmStubId; }
     56 
     57  bool SetServerCertificate(const nsTArray<uint8_t>& aCert);
     58 
     59 private:
     60  const nsString mKeySystem;
     61  java::MediaDrmProxy::GlobalRef mBridgeProxy;
     62  java::MediaDrmProxy::NativeMediaDrmProxyCallbacks::GlobalRef mJavaCallbacks;
     63  bool mDestroyed;
     64  nsString mMediaDrmStubId;
     65 };
     66 
     67 }  // namespace mozilla
     68 #endif  // MediaDrmProxySupport_H