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 VorbisTrackEncoder_h_ michael@0: #define VorbisTrackEncoder_h_ michael@0: michael@0: #include "TrackEncoder.h" michael@0: #include "nsCOMPtr.h" michael@0: #include michael@0: michael@0: namespace mozilla { michael@0: michael@0: class VorbisTrackEncoder : public AudioTrackEncoder michael@0: { michael@0: public: michael@0: VorbisTrackEncoder(); michael@0: virtual ~VorbisTrackEncoder(); michael@0: michael@0: already_AddRefed GetMetadata() MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: nsresult GetEncodedTrack(EncodedFrameContainer& aData) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: protected: michael@0: /** michael@0: * http://xiph.org/vorbis/doc/libvorbis/vorbis_analysis_buffer.html michael@0: * We use 1024 samples for the write buffer; libvorbis will construct packets michael@0: * with the appropriate duration for the encoding mode internally. michael@0: */ michael@0: int GetPacketDuration() MOZ_FINAL MOZ_OVERRIDE { michael@0: return 1024; michael@0: } michael@0: michael@0: nsresult Init(int aChannels, int aSamplingRate) MOZ_FINAL MOZ_OVERRIDE; michael@0: michael@0: private: michael@0: // Write Xiph-style lacing to aOutput. michael@0: void WriteLacing(nsTArray *aOutput, int32_t aLacing); michael@0: michael@0: // Get the encoded data from vorbis encoder and append into aData. michael@0: void GetEncodedFrames(EncodedFrameContainer& aData); michael@0: michael@0: // vorbis codec members michael@0: // Struct that stores all the static vorbis bitstream settings. michael@0: vorbis_info mVorbisInfo; michael@0: // Central working state for the PCM->packet encoder. michael@0: vorbis_dsp_state mVorbisDsp; michael@0: // Local working space for PCM->packet encode. michael@0: vorbis_block mVorbisBlock; michael@0: }; michael@0: michael@0: } michael@0: #endif