MediaEncryptedEvent.h (1948B)
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 mozilla_dom_MediaKeyNeededEvent_h__ 8 #define mozilla_dom_MediaKeyNeededEvent_h__ 9 10 #include <cstdint> 11 12 #include "js/RootingAPI.h" 13 #include "mozilla/AlreadyAddRefed.h" 14 #include "mozilla/dom/Event.h" 15 #include "nsCycleCollectionParticipant.h" 16 #include "nsISupports.h" 17 #include "nsStringFwd.h" 18 #include "nsTArray.h" 19 20 namespace mozilla::dom { 21 struct MediaKeyNeededEventInit; 22 23 class MediaEncryptedEvent final : public Event { 24 public: 25 NS_DECL_ISUPPORTS_INHERITED 26 NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(MediaEncryptedEvent, 27 Event) 28 protected: 29 virtual ~MediaEncryptedEvent(); 30 explicit MediaEncryptedEvent(EventTarget* aOwner); 31 32 nsString mInitDataType; 33 JS::Heap<JSObject*> mInitData; 34 35 public: 36 JSObject* WrapObjectInternal(JSContext* aCx, 37 JS::Handle<JSObject*> aGivenProto) override; 38 39 static already_AddRefed<MediaEncryptedEvent> Constructor(EventTarget* aOwner); 40 41 static already_AddRefed<MediaEncryptedEvent> Constructor( 42 EventTarget* aOwner, const nsAString& aInitDataType, 43 const nsTArray<uint8_t>& aInitData); 44 45 static already_AddRefed<MediaEncryptedEvent> Constructor( 46 const GlobalObject& aGlobal, const nsAString& aType, 47 const MediaKeyNeededEventInit& aEventInitDict, ErrorResult& aRv); 48 49 void GetInitDataType(nsString& aRetVal) const; 50 51 void GetInitData(JSContext* cx, JS::MutableHandle<JSObject*> aData, 52 ErrorResult& aRv); 53 54 private: 55 nsTArray<uint8_t> mRawInitData; 56 }; 57 58 } // namespace mozilla::dom 59 60 #endif // mozilla_dom_MediaKeyNeededEvent_h__