1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/content/media/ogg/OpusParser.h Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,54 @@ 1.4 +/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ 1.5 +/* vim:set ts=2 sw=2 sts=2 et cindent: */ 1.6 +/* This Source Code Form is subject to the terms of the Mozilla Public 1.7 + * License, v. 2.0. If a copy of the MPL was not distributed with this 1.8 + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ 1.9 +#if !defined(OpusParser_h_) 1.10 +#define OpusParser_h_ 1.11 + 1.12 +#include <stdint.h> 1.13 + 1.14 +#include <opus/opus.h> 1.15 +#include "opus/opus_multistream.h" 1.16 + 1.17 +#include "nsTArray.h" 1.18 +#include "nsString.h" 1.19 + 1.20 +namespace mozilla { 1.21 + 1.22 +class OpusParser 1.23 +{ 1.24 +public: 1.25 + OpusParser(); 1.26 + 1.27 + bool DecodeHeader(unsigned char* aData, size_t aLength); 1.28 + bool DecodeTags(unsigned char* aData, size_t aLength); 1.29 + 1.30 + // Various fields from the Ogg Opus header. 1.31 + int mRate; // Sample rate the decoder uses (always 48 kHz). 1.32 + uint32_t mNominalRate; // Original sample rate of the data (informational). 1.33 + int mChannels; // Number of channels the stream encodes. 1.34 + uint16_t mPreSkip; // Number of samples to strip after decoder reset. 1.35 +#ifdef MOZ_SAMPLE_TYPE_FLOAT32 1.36 + float mGain; // Gain to apply to decoder output. 1.37 +#else 1.38 + int32_t mGain_Q16; // Gain to apply to the decoder output. 1.39 +#endif 1.40 + int mChannelMapping; // Channel mapping family. 1.41 + int mStreams; // Number of packed streams in each packet. 1.42 + int mCoupledStreams; // Number of packed coupled streams in each packet. 1.43 + unsigned char mMappingTable[255]; // Channel mapping table. 1.44 + 1.45 + // Granule position (end sample) of the last decoded Opus packet. This is 1.46 + // used to calculate the amount we should trim from the last packet. 1.47 + int64_t mPrevPacketGranulepos; 1.48 + 1.49 + nsTArray<nsCString> mTags; // Unparsed comment strings from the header. 1.50 + 1.51 + nsCString mVendorString; // Encoder vendor string from the header. 1.52 + 1.53 +}; 1.54 + 1.55 +} // namespace mozilla 1.56 + 1.57 +#endif