michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ michael@0: /* This Source Code Form is subject to the terms of the Mozilla Public michael@0: * License, v. 2.0. If a copy of the MPL was not distributed with this file, michael@0: * You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: michael@0: #ifndef WebMWriter_h_ michael@0: #define WebMWriter_h_ michael@0: michael@0: #include "ContainerWriter.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class EbmlComposer; michael@0: michael@0: // Vorbis meta data structure michael@0: class VorbisMetadata : public TrackMetadataBase michael@0: { michael@0: public: michael@0: nsTArray mData; michael@0: int32_t mChannels; michael@0: int32_t mBitDepth; michael@0: float mSamplingFrequency; michael@0: MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VORBIS; } michael@0: }; michael@0: michael@0: // VP8 meta data structure michael@0: class VP8Metadata : public TrackMetadataBase michael@0: { michael@0: public: michael@0: int32_t mWidth; michael@0: int32_t mHeight; michael@0: int32_t mDisplayWidth; michael@0: int32_t mDisplayHeight; michael@0: int32_t mEncodedFrameRate; michael@0: MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VP8; } michael@0: }; michael@0: michael@0: /** michael@0: * WebM writer helper michael@0: * This class accepts encoder to set audio or video meta data or michael@0: * encoded data to ebml Composer, and get muxing data through GetContainerData. michael@0: * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder thread. michael@0: */ michael@0: class WebMWriter : public ContainerWriter michael@0: { michael@0: public: michael@0: // aTrackTypes indicate this muxer should multiplex into Video only or A/V foramt. michael@0: // Run in MediaRecorder thread michael@0: WebMWriter(uint32_t aTrackTypes); michael@0: // WriteEncodedTrack inserts raw packets into WebM stream. michael@0: nsresult WriteEncodedTrack(const EncodedFrameContainer &aData, michael@0: uint32_t aFlags = 0) MOZ_OVERRIDE; michael@0: michael@0: // GetContainerData outputs multiplexing data. michael@0: // aFlags indicates the muxer should enter into finished stage and flush out michael@0: // queue data. michael@0: nsresult GetContainerData(nsTArray >* aOutputBufs, michael@0: uint32_t aFlags = 0) MOZ_OVERRIDE; michael@0: michael@0: // Assign metadata into muxer michael@0: nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: nsAutoPtr mEbmlComposer; michael@0: michael@0: // Indicate what kind of meta data needed in the writer. michael@0: // If this value become 0, it means writer can start to generate header. michael@0: uint8_t mMetadataRequiredFlag; michael@0: }; michael@0: michael@0: } michael@0: #endif