tor-browser

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

VideoEncoder.h (2314B)


      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_VideoEncoder_h
      8 #define mozilla_dom_VideoEncoder_h
      9 
     10 #include "js/TypeDecls.h"
     11 #include "mozilla/ErrorResult.h"
     12 #include "mozilla/RefPtr.h"
     13 #include "mozilla/dom/BindingDeclarations.h"
     14 #include "mozilla/dom/EncoderTemplate.h"
     15 #include "mozilla/dom/EncoderTypes.h"
     16 #include "mozilla/dom/VideoFrame.h"
     17 #include "nsCycleCollectionParticipant.h"
     18 
     19 class nsIGlobalObject;
     20 
     21 namespace mozilla {
     22 
     23 namespace dom {
     24 
     25 class EncodedVideoChunk;
     26 class EncodedVideoChunkData;
     27 class EventHandlerNonNull;
     28 class GlobalObject;
     29 class Promise;
     30 class VideoFrameOutputCallback;
     31 class WebCodecsErrorCallback;
     32 struct VideoEncoderConfig;
     33 struct VideoEncoderInit;
     34 
     35 }  // namespace dom
     36 
     37 }  // namespace mozilla
     38 
     39 namespace mozilla::dom {
     40 
     41 class VideoEncoder final : public EncoderTemplate<VideoEncoderTraits> {
     42 public:
     43  NS_DECL_ISUPPORTS_INHERITED
     44  NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(VideoEncoder, DOMEventTargetHelper)
     45 
     46 public:
     47  VideoEncoder(nsIGlobalObject* aParent,
     48               RefPtr<WebCodecsErrorCallback>&& aErrorCallback,
     49               RefPtr<EncodedVideoChunkOutputCallback>&& aOutputCallback);
     50 
     51 protected:
     52  ~VideoEncoder();
     53 
     54 public:
     55  JSObject* WrapObject(JSContext* aCx,
     56                       JS::Handle<JSObject*> aGivenProto) override;
     57 
     58  static already_AddRefed<VideoEncoder> Constructor(
     59      const GlobalObject& aGlobal, const VideoEncoderInit& aInit,
     60      ErrorResult& aRv);
     61 
     62  static already_AddRefed<Promise> IsConfigSupported(
     63      const GlobalObject& aGlobal, const VideoEncoderConfig& aConfig,
     64      ErrorResult& aRv);
     65 
     66 protected:
     67  virtual RefPtr<EncodedVideoChunk> EncodedDataToOutputType(
     68      nsIGlobalObject* aGlobal, const RefPtr<MediaRawData>& aData) override;
     69 
     70  virtual void EncoderConfigToDecoderConfig(
     71      JSContext* aCx, const RefPtr<MediaRawData>& aRawData,
     72      const VideoEncoderConfigInternal& aSrcConfig,
     73      VideoDecoderConfig& aDestConfig) const override;
     74 };
     75 
     76 }  // namespace mozilla::dom
     77 
     78 #endif  // mozilla_dom_VideoEncoder_h