Added histogram for v2 app launch source
[chromium-blink-merge.git] / media / mp4 / aac.h
blobe12b6a4d9ff4ef91ad8b0309258eddf43df47366
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef MEDIA_MP4_AAC_H_
6 #define MEDIA_MP4_AAC_H_
8 #include <vector>
10 #include "base/basictypes.h"
11 #include "media/base/channel_layout.h"
12 #include "media/base/media_export.h"
14 namespace media {
16 class BitReader;
18 namespace mp4 {
20 // This class parses the AAC information from decoder specific information
21 // embedded in the esds box in an ISO BMFF file.
22 // Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
23 // for more details.
24 class MEDIA_EXPORT AAC {
25 public:
26 AAC();
27 ~AAC();
29 // Parse the AAC config from the raw binary data embedded in esds box.
30 // The function will parse the data and get the ElementaryStreamDescriptor,
31 // then it will parse the ElementaryStreamDescriptor to get audio stream
32 // configurations.
33 bool Parse(const std::vector<uint8>& data);
35 // Gets the output sample rate for the AAC stream.
36 // |sbr_in_mimetype| should be set to true if the SBR mode is
37 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
38 // Returns the samples_per_second value that should used in an
39 // AudioDecoderConfig.
40 int GetOutputSamplesPerSecond(bool sbr_in_mimetype) const;
41 ChannelLayout channel_layout() const;
43 // This function converts a raw AAC frame into an AAC frame with an ADTS
44 // header. On success, the function returns true and stores the converted data
45 // in the buffer. The function returns false on failure and leaves the buffer
46 // unchanged.
47 bool ConvertEsdsToADTS(std::vector<uint8>* buffer) const;
49 // Size in bytes of the ADTS header added by ConvertEsdsToADTS().
50 static const size_t kADTSHeaderSize = 7;
52 private:
53 bool SkipDecoderGASpecificConfig(BitReader* bit_reader) const;
54 bool SkipErrorSpecificConfig() const;
55 bool SkipGASpecificConfig(BitReader* bit_reader) const;
57 // The following variables store the AAC specific configuration information
58 // that are used to generate the ADTS header.
59 uint8 profile_;
60 uint8 frequency_index_;
61 uint8 channel_config_;
63 // The following variables store audio configuration information that
64 // can be used by Chromium. They are based on the AAC specific
65 // configuration but can be overridden by extensions in elementary
66 // stream descriptor.
67 int frequency_;
68 int extension_frequency_;
69 ChannelLayout channel_layout_;
72 } // namespace mp4
74 } // namespace media
76 #endif // MEDIA_MP4_AAC_H_