Fri, 16 Jan 2015 04:50:19 +0100
Replace accessor implementation with direct member state manipulation, by
request https://trac.torproject.org/projects/tor/ticket/9701#comment:32
michael@0 | 1 | /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-*/ |
michael@0 | 2 | /* This Source Code Form is subject to the terms of the Mozilla Public |
michael@0 | 3 | * License, v. 2.0. If a copy of the MPL was not distributed with this file, |
michael@0 | 4 | * You can obtain one at http://mozilla.org/MPL/2.0/. */ |
michael@0 | 5 | |
michael@0 | 6 | #ifndef WebMWriter_h_ |
michael@0 | 7 | #define WebMWriter_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "ContainerWriter.h" |
michael@0 | 10 | |
michael@0 | 11 | namespace mozilla { |
michael@0 | 12 | |
michael@0 | 13 | class EbmlComposer; |
michael@0 | 14 | |
michael@0 | 15 | // Vorbis meta data structure |
michael@0 | 16 | class VorbisMetadata : public TrackMetadataBase |
michael@0 | 17 | { |
michael@0 | 18 | public: |
michael@0 | 19 | nsTArray<uint8_t> mData; |
michael@0 | 20 | int32_t mChannels; |
michael@0 | 21 | int32_t mBitDepth; |
michael@0 | 22 | float mSamplingFrequency; |
michael@0 | 23 | MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VORBIS; } |
michael@0 | 24 | }; |
michael@0 | 25 | |
michael@0 | 26 | // VP8 meta data structure |
michael@0 | 27 | class VP8Metadata : public TrackMetadataBase |
michael@0 | 28 | { |
michael@0 | 29 | public: |
michael@0 | 30 | int32_t mWidth; |
michael@0 | 31 | int32_t mHeight; |
michael@0 | 32 | int32_t mDisplayWidth; |
michael@0 | 33 | int32_t mDisplayHeight; |
michael@0 | 34 | int32_t mEncodedFrameRate; |
michael@0 | 35 | MetadataKind GetKind() const MOZ_OVERRIDE { return METADATA_VP8; } |
michael@0 | 36 | }; |
michael@0 | 37 | |
michael@0 | 38 | /** |
michael@0 | 39 | * WebM writer helper |
michael@0 | 40 | * This class accepts encoder to set audio or video meta data or |
michael@0 | 41 | * encoded data to ebml Composer, and get muxing data through GetContainerData. |
michael@0 | 42 | * The ctor/dtor run in the MediaRecorder thread, others run in MediaEncoder thread. |
michael@0 | 43 | */ |
michael@0 | 44 | class WebMWriter : public ContainerWriter |
michael@0 | 45 | { |
michael@0 | 46 | public: |
michael@0 | 47 | // aTrackTypes indicate this muxer should multiplex into Video only or A/V foramt. |
michael@0 | 48 | // Run in MediaRecorder thread |
michael@0 | 49 | WebMWriter(uint32_t aTrackTypes); |
michael@0 | 50 | // WriteEncodedTrack inserts raw packets into WebM stream. |
michael@0 | 51 | nsresult WriteEncodedTrack(const EncodedFrameContainer &aData, |
michael@0 | 52 | uint32_t aFlags = 0) MOZ_OVERRIDE; |
michael@0 | 53 | |
michael@0 | 54 | // GetContainerData outputs multiplexing data. |
michael@0 | 55 | // aFlags indicates the muxer should enter into finished stage and flush out |
michael@0 | 56 | // queue data. |
michael@0 | 57 | nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs, |
michael@0 | 58 | uint32_t aFlags = 0) MOZ_OVERRIDE; |
michael@0 | 59 | |
michael@0 | 60 | // Assign metadata into muxer |
michael@0 | 61 | nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE; |
michael@0 | 62 | |
michael@0 | 63 | private: |
michael@0 | 64 | nsAutoPtr<EbmlComposer> mEbmlComposer; |
michael@0 | 65 | |
michael@0 | 66 | // Indicate what kind of meta data needed in the writer. |
michael@0 | 67 | // If this value become 0, it means writer can start to generate header. |
michael@0 | 68 | uint8_t mMetadataRequiredFlag; |
michael@0 | 69 | }; |
michael@0 | 70 | |
michael@0 | 71 | } |
michael@0 | 72 | #endif |