michael@0: /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ michael@0: /* vim:set ts=2 sw=2 sts=2 et cindent: */ 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 michael@0: * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ michael@0: #if !defined(OpusParser_h_) michael@0: #define OpusParser_h_ michael@0: michael@0: #include michael@0: michael@0: #include michael@0: #include "opus/opus_multistream.h" michael@0: michael@0: #include "nsTArray.h" michael@0: #include "nsString.h" michael@0: michael@0: namespace mozilla { michael@0: michael@0: class OpusParser michael@0: { michael@0: public: michael@0: OpusParser(); michael@0: michael@0: bool DecodeHeader(unsigned char* aData, size_t aLength); michael@0: bool DecodeTags(unsigned char* aData, size_t aLength); michael@0: michael@0: // Various fields from the Ogg Opus header. michael@0: int mRate; // Sample rate the decoder uses (always 48 kHz). michael@0: uint32_t mNominalRate; // Original sample rate of the data (informational). michael@0: int mChannels; // Number of channels the stream encodes. michael@0: uint16_t mPreSkip; // Number of samples to strip after decoder reset. michael@0: #ifdef MOZ_SAMPLE_TYPE_FLOAT32 michael@0: float mGain; // Gain to apply to decoder output. michael@0: #else michael@0: int32_t mGain_Q16; // Gain to apply to the decoder output. michael@0: #endif michael@0: int mChannelMapping; // Channel mapping family. michael@0: int mStreams; // Number of packed streams in each packet. michael@0: int mCoupledStreams; // Number of packed coupled streams in each packet. michael@0: unsigned char mMappingTable[255]; // Channel mapping table. michael@0: michael@0: // Granule position (end sample) of the last decoded Opus packet. This is michael@0: // used to calculate the amount we should trim from the last packet. michael@0: int64_t mPrevPacketGranulepos; michael@0: michael@0: nsTArray mTags; // Unparsed comment strings from the header. michael@0: michael@0: nsCString mVendorString; // Encoder vendor string from the header. michael@0: michael@0: }; michael@0: michael@0: } // namespace mozilla michael@0: michael@0: #endif