1 // Copyright 2014 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_FORMATS_MP4_AAC_H_
6 #define MEDIA_FORMATS_MP4_AAC_H_
10 #include "base/basictypes.h"
11 #include "media/base/channel_layout.h"
12 #include "media/base/media_export.h"
13 #include "media/base/media_log.h"
21 // This class parses the AAC information from decoder specific information
22 // embedded in the esds box in an ISO BMFF file.
23 // Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
25 class MEDIA_EXPORT AAC
{
30 // Parse the AAC config from the raw binary data embedded in esds box.
31 // The function will parse the data and get the ElementaryStreamDescriptor,
32 // then it will parse the ElementaryStreamDescriptor to get audio stream
34 bool Parse(const std::vector
<uint8
>& data
, const LogCB
& log_cb
);
36 // Gets the output sample rate for the AAC stream.
37 // |sbr_in_mimetype| should be set to true if the SBR mode is
38 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
39 // Returns the samples_per_second value that should used in an
40 // AudioDecoderConfig.
41 int GetOutputSamplesPerSecond(bool sbr_in_mimetype
) const;
43 // Gets the channel layout for the AAC stream.
44 // |sbr_in_mimetype| should be set to true if the SBR mode is
45 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter).
46 // Returns the channel_layout value that should used in an
47 // AudioDecoderConfig.
48 ChannelLayout
GetChannelLayout(bool sbr_in_mimetype
) const;
50 // This function converts a raw AAC frame into an AAC frame with an ADTS
51 // header. On success, the function returns true and stores the converted data
52 // in the buffer. The function returns false on failure and leaves the buffer
54 bool ConvertEsdsToADTS(std::vector
<uint8
>* buffer
) const;
56 #if defined(OS_ANDROID)
57 // Returns the codec specific data needed by android MediaCodec.
58 std::vector
<uint8
> codec_specific_data() const {
59 return codec_specific_data_
;
64 bool SkipDecoderGASpecificConfig(BitReader
* bit_reader
) const;
65 bool SkipErrorSpecificConfig() const;
66 bool SkipGASpecificConfig(BitReader
* bit_reader
) const;
68 // The following variables store the AAC specific configuration information
69 // that are used to generate the ADTS header.
71 uint8 frequency_index_
;
72 uint8 channel_config_
;
74 #if defined(OS_ANDROID)
75 // The codec specific data needed by the android MediaCodec.
76 std::vector
<uint8
> codec_specific_data_
;
79 // The following variables store audio configuration information that
80 // can be used by Chromium. They are based on the AAC specific
81 // configuration but can be overridden by extensions in elementary
84 int extension_frequency_
;
85 ChannelLayout channel_layout_
;
92 #endif // MEDIA_FORMATS_MP4_AAC_H_