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 OggWriter_h_ |
michael@0 | 7 | #define OggWriter_h_ |
michael@0 | 8 | |
michael@0 | 9 | #include "ContainerWriter.h" |
michael@0 | 10 | #include "OpusTrackEncoder.h" |
michael@0 | 11 | #include <ogg/ogg.h> |
michael@0 | 12 | |
michael@0 | 13 | namespace mozilla { |
michael@0 | 14 | /** |
michael@0 | 15 | * WriteEncodedTrack inserts raw packets into Ogg stream (ogg_stream_state), and |
michael@0 | 16 | * GetContainerData outputs an ogg_page when enough packets have been written |
michael@0 | 17 | * to the Ogg stream. |
michael@0 | 18 | * For more details, please reference: |
michael@0 | 19 | * http://www.xiph.org/ogg/doc/libogg/encoding.html |
michael@0 | 20 | */ |
michael@0 | 21 | class OggWriter : public ContainerWriter |
michael@0 | 22 | { |
michael@0 | 23 | public: |
michael@0 | 24 | OggWriter(); |
michael@0 | 25 | ~OggWriter(); |
michael@0 | 26 | |
michael@0 | 27 | nsresult WriteEncodedTrack(const EncodedFrameContainer &aData, |
michael@0 | 28 | uint32_t aFlags = 0) MOZ_OVERRIDE; |
michael@0 | 29 | |
michael@0 | 30 | nsresult GetContainerData(nsTArray<nsTArray<uint8_t> >* aOutputBufs, |
michael@0 | 31 | uint32_t aFlags = 0) MOZ_OVERRIDE; |
michael@0 | 32 | |
michael@0 | 33 | // Check metadata type integrity and reject unacceptable track encoder. |
michael@0 | 34 | nsresult SetMetadata(TrackMetadataBase* aMetadata) MOZ_OVERRIDE; |
michael@0 | 35 | private: |
michael@0 | 36 | nsresult Init(); |
michael@0 | 37 | |
michael@0 | 38 | nsresult WriteEncodedData(const nsTArray<uint8_t>& aBuffer, int aDuration, |
michael@0 | 39 | uint32_t aFlags = 0); |
michael@0 | 40 | |
michael@0 | 41 | void ProduceOggPage(nsTArray<nsTArray<uint8_t> >* aOutputBufs); |
michael@0 | 42 | // Store the Medatata from track encoder |
michael@0 | 43 | nsRefPtr<OpusMetadata> mMetadata; |
michael@0 | 44 | |
michael@0 | 45 | ogg_stream_state mOggStreamState; |
michael@0 | 46 | ogg_page mOggPage; |
michael@0 | 47 | ogg_packet mPacket; |
michael@0 | 48 | }; |
michael@0 | 49 | } |
michael@0 | 50 | #endif |