content/media/webm/WebMWriter.h

changeset 0
6474c204b198
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/content/media/webm/WebMWriter.h	Wed Dec 31 06:09:35 2014 +0100
     1.3 @@ -0,0 +1,72 @@
     1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/
     1.5 +/* This Source Code Form is subject to the terms of the Mozilla Public
     1.6 + * License, v. 2.0. If a copy of the MPL was not distributed with this file,
     1.7 + * You can obtain one at http://mozilla.org/MPL/2.0/. */
     1.8 +
     1.9 +#ifndef WebMWriter_h_
    1.10 +#define WebMWriter_h_
    1.11 +
    1.12 +#include "ContainerWriter.h"
    1.13 +
    1.14 +namespace mozilla {
    1.15 +
    1.16 +class EbmlComposer;
    1.17 +
    1.18 +// Vorbis meta data structure
    1.19 +class VorbisMetadata : public TrackMetadataBase
    1.20 +{
    1.21 +public:
    1.22 +  nsTArray<uint8_t> mData;
    1.23 +  int32_t mChannels;
    1.24 +  int32_t mBitDepth;
    1.25 +  float mSamplingFrequency;
    1.26 +  MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VORBIS; }
    1.27 +};
    1.28 +
    1.29 +// VP8 meta data structure
    1.30 +class VP8Metadata : public TrackMetadataBase
    1.31 +{
    1.32 +public:
    1.33 +  int32_t mWidth;
    1.34 +  int32_t mHeight;
    1.35 +  int32_t mDisplayWidth;
    1.36 +  int32_t mDisplayHeight;
    1.37 +  int32_t mEncodedFrameRate;
    1.38 +  MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VP8; }
    1.39 +};
    1.40 +
    1.41 +/**
    1.42 + * WebM writer helper
    1.43 + * This class accepts encoder to set audio or video meta data or
    1.44 + * encoded data to ebml Composer, and get muxing data through GetContainerData.
    1.45 + * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder thread.
    1.46 + */
    1.47 +class WebMWriter : public ContainerWriter
    1.48 +{
    1.49 +public:
    1.50 +  // aTrackTypes indicate this muxer should multiplex into Video only or A/V foramt.
    1.51 +  // Run in MediaRecorder thread
    1.52 +  WebMWriter(uint32_t aTrackTypes);
    1.53 +  // WriteEncodedTrack inserts raw packets into WebM stream.
    1.54 +  nsresult WriteEncodedTrack(const EncodedFrameContainer &aData,
    1.55 +                             uint32_t aFlags = 0) MOZ_OVERRIDE;
    1.56 +
    1.57 +  // GetContainerData outputs multiplexing data.
    1.58 +  // aFlags indicates the muxer should enter into finished stage and flush out
    1.59 +  // queue data.
    1.60 +  nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs,
    1.61 +                            uint32_t aFlags = 0) MOZ_OVERRIDE;
    1.62 +
    1.63 +  // Assign metadata into muxer
    1.64 +  nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE;
    1.65 +
    1.66 +private:
    1.67 +  nsAutoPtr<EbmlComposer> mEbmlComposer;
    1.68 +
    1.69 +  // Indicate what kind of meta data needed in the writer.
    1.70 +  // If this value become 0, it means writer can start to generate header.
    1.71 +  uint8_t mMetadataRequiredFlag;
    1.72 +};
    1.73 +
    1.74 +}
    1.75 +#endif

mercurial