dom/media/eme/MediaKeySystemAccess.h
author Mozilla Releng Treescript <release+treescript@mozilla.org>
Fri, 28 Jan 2022 19:05:43 +0000
changeset 605836 32a2d1ce4bab2979c3be01244f100f000ca77d8e
parent 558383 74111dd7a5008bf77ffaeaf5cfaf380296317822
permissions -rw-r--r--
no bug - Bumping Firefox l10n changesets r=release a=l10n-bump DONTBUILD cy -> 0eecc3c5396a7ce0ae207243a6879f559761b7a3 de -> 9220d3a92bcdc0287d9fedf94dfff7053058ccf1 fr -> 43ef41efa9e6ff87d6b4d0672d44c6d0d02f078c hsb -> 5d446c2cb85ab7fc253ec1b4fb6ed55438b0ef0f hye -> c5edf78a6f636234bb8bba68726a237d4ff9c397 it -> aa7f02187d8cecb017436efd84bf96faf8fbf63c nl -> ce81040d4aa33f478a2b20a5762f720c94b34ae6 sl -> dc3ce6db84b4e461483b2f3f25b0c627b69e446c uk -> 3deee0c202358c3bec34a0d3975ef764abf223a4

/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
/* vim:set ts=2 sw=2 sts=2 et cindent: */
/* 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/. */

#ifndef mozilla_dom_MediaKeySystemAccess_h
#define mozilla_dom_MediaKeySystemAccess_h

#include "mozilla/Attributes.h"
#include "nsCycleCollectionParticipant.h"
#include "nsWrapperCache.h"

#include "mozilla/dom/Promise.h"
#include "mozilla/dom/MediaKeySystemAccessBinding.h"
#include "mozilla/dom/MediaKeysRequestStatusBinding.h"

#include "js/TypeDecls.h"

namespace mozilla {

class DecoderDoctorDiagnostics;
class ErrorResult;

namespace dom {

class MediaKeySystemAccess final : public nsISupports, public nsWrapperCache {
 public:
  NS_DECL_CYCLE_COLLECTING_ISUPPORTS
  NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(MediaKeySystemAccess)

 public:
  explicit MediaKeySystemAccess(nsPIDOMWindowInner* aParent,
                                const nsAString& aKeySystem,
                                const MediaKeySystemConfiguration& aConfig);

 protected:
  ~MediaKeySystemAccess();

 public:
  nsPIDOMWindowInner* GetParentObject() const;

  JSObject* WrapObject(JSContext* aCx,
                       JS::Handle<JSObject*> aGivenProto) override;

  void GetKeySystem(nsString& aRetVal) const;

  void GetConfiguration(MediaKeySystemConfiguration& aConfig);

  already_AddRefed<Promise> CreateMediaKeys(ErrorResult& aRv);

  static MediaKeySystemStatus GetKeySystemStatus(
      const nsAString& aKeySystem, nsACString& aOutExceptionMessage);

  static bool IsSupported(const nsAString& aKeySystem,
                          const Sequence<MediaKeySystemConfiguration>& aConfigs,
                          DecoderDoctorDiagnostics* aDiagnostics);

  static void NotifyObservers(nsPIDOMWindowInner* aWindow,
                              const nsAString& aKeySystem,
                              MediaKeySystemStatus aStatus);

  static bool GetSupportedConfig(
      const nsAString& aKeySystem,
      const Sequence<MediaKeySystemConfiguration>& aConfigs,
      MediaKeySystemConfiguration& aOutConfig,
      DecoderDoctorDiagnostics* aDiagnostics, bool aIsPrivateBrowsing,
      const std::function<void(const char*)>& aDeprecationLogFn);

  static bool KeySystemSupportsInitDataType(const nsAString& aKeySystem,
                                            const nsAString& aInitDataType);

  static nsCString ToCString(
      const Sequence<MediaKeySystemConfiguration>& aConfig);

 private:
  nsCOMPtr<nsPIDOMWindowInner> mParent;
  const nsString mKeySystem;
  const MediaKeySystemConfiguration mConfig;
};

}  // namespace dom
}  // namespace mozilla

#endif  // mozilla_dom_MediaKeySystemAccess_h