OpusParser.h (1811B)
1 /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 2 /* vim:set ts=2 sw=2 sts=2 et cindent: */ 3 /* This Source Code Form is subject to the terms of the Mozilla Public 4 * License, v. 2.0. If a copy of the MPL was not distributed with this 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 6 #if !defined(OpusParser_h_) 7 # define OpusParser_h_ 8 9 # include "nsString.h" 10 # include "nsTArray.h" 11 12 namespace mozilla { 13 14 class OpusParser { 15 public: 16 OpusParser(); 17 18 bool DecodeHeader(unsigned char* aData, size_t aLength); 19 bool DecodeTags(unsigned char* aData, size_t aLength); 20 static bool IsValidMapping2ChannelsCount(uint8_t aChannels); 21 22 // Various fields from the Ogg Opus header. 23 int mRate; // Sample rate the decoder uses (always 48 kHz). 24 uint32_t mNominalRate; // Original sample rate of the data (informational). 25 int mChannels; // Number of channels the stream encodes. 26 uint16_t mPreSkip; // Number of samples to strip after decoder reset. 27 # ifdef MOZ_SAMPLE_TYPE_FLOAT32 28 float mGain; // Gain to apply to decoder output. 29 # else 30 int32_t mGain_Q16; // Gain to apply to the decoder output. 31 # endif 32 int mChannelMapping; // Channel mapping family. 33 int mStreams; // Number of packed streams in each packet. 34 int mCoupledStreams; // Number of packed coupled streams in each packet. 35 unsigned char mMappingTable[255] = {}; // Channel mapping table. 36 37 // Granule position (end sample) of the last decoded Opus packet. This is 38 // used to calculate the amount we should trim from the last packet. 39 int64_t mPrevPacketGranulepos; 40 41 nsTArray<nsCString> mTags; // Unparsed comment strings from the header. 42 43 nsCString mVendorString; // Encoder vendor string from the header. 44 }; 45 46 } // namespace mozilla 47 48 #endif