tor-browser

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

WebMWriter.h (2081B)


      1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
      2 /* This Source Code Form is subject to the terms of the Mozilla Public
      3 * License, v. 2.0. If a copy of the MPL was not distributed with this file,
      4 * You can obtain one at http://mozilla.org/MPL/2.0/. */
      5 
      6 #ifndef WebMWriter_h_
      7 #define WebMWriter_h_
      8 
      9 #include "ContainerWriter.h"
     10 
     11 namespace mozilla {
     12 
     13 class EbmlComposer;
     14 
     15 // Vorbis meta data structure
     16 class VorbisMetadata : public TrackMetadataBase {
     17 public:
     18  nsTArray<uint8_t> mData;
     19  int32_t mChannels;
     20  float mSamplingFrequency;
     21  MetadataKind GetKind() const override { return METADATA_VORBIS; }
     22 };
     23 
     24 // VP8 meta data structure
     25 class VP8Metadata : public TrackMetadataBase {
     26 public:
     27  int32_t mWidth;
     28  int32_t mHeight;
     29  int32_t mDisplayWidth;
     30  int32_t mDisplayHeight;
     31  MetadataKind GetKind() const override { return METADATA_VP8; }
     32 };
     33 
     34 /**
     35 * WebM writer helper
     36 * This class accepts encoder to set audio or video meta data or
     37 * encoded data to ebml Composer, and get muxing data through GetContainerData.
     38 * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder
     39 * thread.
     40 */
     41 class WebMWriter : public ContainerWriter {
     42 public:
     43  // Run in MediaRecorder thread
     44  WebMWriter();
     45  virtual ~WebMWriter();
     46 
     47  // WriteEncodedTrack inserts raw packets into WebM stream. Does not accept
     48  // any flags: any specified will be ignored. Writing is finalized via
     49  // flushing via GetContainerData().
     50  nsresult WriteEncodedTrack(const nsTArray<RefPtr<EncodedFrame>>& aData,
     51                             uint32_t aFlags = 0) override;
     52 
     53  // GetContainerData outputs multiplexing data.
     54  // aFlags indicates the muxer should enter into finished stage and flush out
     55  // queue data.
     56  nsresult GetContainerData(nsTArray<nsTArray<uint8_t>>* aOutputBufs,
     57                            uint32_t aFlags = 0) override;
     58 
     59  // Assign metadata into muxer
     60  nsresult SetMetadata(
     61      const nsTArray<RefPtr<TrackMetadataBase>>& aMetadata) override;
     62 
     63 private:
     64  UniquePtr<EbmlComposer> mEbmlComposer;
     65 };
     66 
     67 }  // namespace mozilla
     68 
     69 #endif