VideoDecoder.h (2383B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 7 #ifndef mozilla_dom_VideoDecoder_h 8 #define mozilla_dom_VideoDecoder_h 9 10 #include "js/TypeDecls.h" 11 #include "mozilla/ErrorResult.h" 12 #include "mozilla/RefPtr.h" 13 #include "mozilla/UniquePtr.h" 14 #include "mozilla/dom/BindingDeclarations.h" 15 #include "mozilla/dom/DecoderTemplate.h" 16 #include "mozilla/dom/DecoderTypes.h" 17 #include "mozilla/dom/VideoFrame.h" 18 #include "nsCycleCollectionParticipant.h" 19 20 class nsIGlobalObject; 21 22 namespace mozilla { 23 24 namespace dom { 25 26 class EncodedVideoChunk; 27 class EncodedVideoChunkData; 28 class EventHandlerNonNull; 29 class GlobalObject; 30 class Promise; 31 class VideoFrameOutputCallback; 32 class WebCodecsErrorCallback; 33 struct VideoDecoderConfig; 34 struct VideoDecoderInit; 35 36 } // namespace dom 37 38 } // namespace mozilla 39 40 namespace mozilla::dom { 41 42 class VideoDecoder final : public DecoderTemplate<VideoDecoderTraits> { 43 public: 44 NS_DECL_ISUPPORTS_INHERITED 45 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VideoDecoder, DOMEventTargetHelper) 46 47 public: 48 VideoDecoder(nsIGlobalObject* aParent, 49 RefPtr<WebCodecsErrorCallback>&& aErrorCallback, 50 RefPtr<VideoFrameOutputCallback>&& aOutputCallback); 51 52 protected: 53 ~VideoDecoder(); 54 55 public: 56 JSObject* WrapObject(JSContext* aCx, 57 JS::Handle<JSObject*> aGivenProto) override; 58 59 static already_AddRefed<VideoDecoder> Constructor( 60 const GlobalObject& aGlobal, const VideoDecoderInit& aInit, 61 ErrorResult& aRv); 62 63 static already_AddRefed<Promise> IsConfigSupported( 64 const GlobalObject& aGlobal, const VideoDecoderConfig& aConfig, 65 ErrorResult& aRv); 66 67 protected: 68 virtual already_AddRefed<MediaRawData> InputDataToMediaRawData( 69 UniquePtr<EncodedVideoChunkData>&& aData, TrackInfo& aInfo, 70 const VideoDecoderConfigInternal& aConfig) override; 71 72 virtual nsTArray<RefPtr<VideoFrame>> DecodedDataToOutputType( 73 nsIGlobalObject* aGlobalObject, const nsTArray<RefPtr<MediaData>>&& aData, 74 const VideoDecoderConfigInternal& aConfig) override; 75 }; 76 77 } // namespace mozilla::dom 78 79 #endif // mozilla_dom_VideoDecoder_h