|
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 <stdint.h> |
|
10 |
|
11 #include <opus/opus.h> |
|
12 #include "opus/opus_multistream.h" |
|
13 |
|
14 #include "nsTArray.h" |
|
15 #include "nsString.h" |
|
16 |
|
17 namespace mozilla { |
|
18 |
|
19 class OpusParser |
|
20 { |
|
21 public: |
|
22 OpusParser(); |
|
23 |
|
24 bool DecodeHeader(unsigned char* aData, size_t aLength); |
|
25 bool DecodeTags(unsigned char* aData, size_t aLength); |
|
26 |
|
27 // Various fields from the Ogg Opus header. |
|
28 int mRate; // Sample rate the decoder uses (always 48 kHz). |
|
29 uint32_t mNominalRate; // Original sample rate of the data (informational). |
|
30 int mChannels; // Number of channels the stream encodes. |
|
31 uint16_t mPreSkip; // Number of samples to strip after decoder reset. |
|
32 #ifdef MOZ_SAMPLE_TYPE_FLOAT32 |
|
33 float mGain; // Gain to apply to decoder output. |
|
34 #else |
|
35 int32_t mGain_Q16; // Gain to apply to the decoder output. |
|
36 #endif |
|
37 int mChannelMapping; // Channel mapping family. |
|
38 int mStreams; // Number of packed streams in each packet. |
|
39 int mCoupledStreams; // Number of packed coupled streams in each packet. |
|
40 unsigned char mMappingTable[255]; // Channel mapping table. |
|
41 |
|
42 // Granule position (end sample) of the last decoded Opus packet. This is |
|
43 // used to calculate the amount we should trim from the last packet. |
|
44 int64_t mPrevPacketGranulepos; |
|
45 |
|
46 nsTArray<nsCString> mTags; // Unparsed comment strings from the header. |
|
47 |
|
48 nsCString mVendorString; // Encoder vendor string from the header. |
|
49 |
|
50 }; |
|
51 |
|
52 } // namespace mozilla |
|
53 |
|
54 #endif |