AudioDecoder.h (2449B)
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_AudioDecoder_h 8 #define mozilla_dom_AudioDecoder_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/AudioData.h" 15 #include "mozilla/dom/BindingDeclarations.h" 16 #include "mozilla/dom/DecoderTemplate.h" 17 #include "mozilla/dom/DecoderTypes.h" 18 #include "mozilla/dom/RootedDictionary.h" 19 #include "nsCycleCollectionParticipant.h" 20 #include "nsWrapperCache.h" 21 22 class nsIGlobalObject; 23 24 namespace mozilla { 25 26 namespace dom { 27 28 class AudioDataOutputCallback; 29 class EncodedAudioChunk; 30 class EncodedAudioChunkData; 31 class EventHandlerNonNull; 32 class GlobalObject; 33 class Promise; 34 class WebCodecsErrorCallback; 35 struct AudioDecoderConfig; 36 struct AudioDecoderInit; 37 38 } // namespace dom 39 40 } // namespace mozilla 41 42 namespace mozilla::dom { 43 44 class AudioDecoder final : public DecoderTemplate<AudioDecoderTraits> { 45 public: 46 NS_DECL_ISUPPORTS_INHERITED 47 NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(AudioDecoder, DOMEventTargetHelper) 48 49 public: 50 AudioDecoder(nsIGlobalObject* aParent, 51 RefPtr<WebCodecsErrorCallback>&& aErrorCallback, 52 RefPtr<AudioDataOutputCallback>&& aOutputCallback); 53 54 protected: 55 ~AudioDecoder(); 56 57 public: 58 JSObject* WrapObject(JSContext* aCx, 59 JS::Handle<JSObject*> aGivenProto) override; 60 61 static already_AddRefed<AudioDecoder> Constructor( 62 const GlobalObject& aGlobal, const AudioDecoderInit& aInit, 63 ErrorResult& aRv); 64 65 static already_AddRefed<Promise> IsConfigSupported( 66 const GlobalObject& aGlobal, const AudioDecoderConfig& aConfig, 67 ErrorResult& aRv); 68 69 protected: 70 virtual already_AddRefed<MediaRawData> InputDataToMediaRawData( 71 UniquePtr<EncodedAudioChunkData>&& aData, TrackInfo& aInfo, 72 const AudioDecoderConfigInternal& aConfig) override; 73 74 virtual nsTArray<RefPtr<AudioData>> DecodedDataToOutputType( 75 nsIGlobalObject* aGlobalObject, const nsTArray<RefPtr<MediaData>>&& aData, 76 const AudioDecoderConfigInternal& aConfig) override; 77 }; 78 79 } // namespace mozilla::dom 80 81 #endif // mozilla_dom_AudioDecoder_h