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 OggWriter_h_ michael@0: #define OggWriter_h_ michael@0: michael@0: #include "ContainerWriter.h" michael@0: #include "OpusTrackEncoder.h" michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: /** michael@0: * WriteEncodedTrack inserts raw packets into Ogg stream (ogg_stream_state), and michael@0: * GetContainerData outputs an ogg_page when enough packets have been written michael@0: * to the Ogg stream. michael@0: * For more details, please reference: michael@0: * http://www.xiph.org/ogg/doc/libogg/encoding.html michael@0: */ michael@0: class OggWriter : public ContainerWriter michael@0: { michael@0: public: michael@0: OggWriter(); michael@0: ~OggWriter(); michael@0: michael@0: nsresult WriteEncodedTrack(const EncodedFrameContainer &aData, michael@0: uint32_t aFlags = 0) MOZ_OVERRIDE; michael@0: michael@0: nsresult GetContainerData(nsTArray >* aOutputBufs, michael@0: uint32_t aFlags = 0) MOZ_OVERRIDE; michael@0: michael@0: // Check metadata type integrity and reject unacceptable track encoder. michael@0: nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE; michael@0: private: michael@0: nsresult Init(); michael@0: michael@0: nsresult WriteEncodedData(const nsTArray& aBuffer, int aDuration, michael@0: uint32_t aFlags = 0); michael@0: michael@0: void ProduceOggPage(nsTArray >* aOutputBufs); michael@0: // Store the Medatata from track encoder michael@0: nsRefPtr mMetadata; michael@0: michael@0: ogg_stream_state mOggStreamState; michael@0: ogg_page mOggPage; michael@0: ogg_packet mPacket; michael@0: }; michael@0: } michael@0: #endif