| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #ifndef MEDIA_FORMATS_MP4_AAC_H_ | 5 #ifndef MEDIA_FORMATS_MP4_AAC_H_ |
| 6 #define MEDIA_FORMATS_MP4_AAC_H_ | 6 #define MEDIA_FORMATS_MP4_AAC_H_ |
| 7 | 7 |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | |
| 11 #include "media/base/channel_layout.h" | 10 #include "media/base/channel_layout.h" |
| 12 #include "media/base/media_export.h" | 11 #include "media/base/media_export.h" |
| 13 #include "media/base/media_log.h" | 12 #include "media/base/media_log.h" |
| 14 | 13 |
| 15 namespace media { | 14 namespace media { |
| 16 | 15 |
| 17 class BitReader; | 16 class BitReader; |
| 18 | 17 |
| 19 namespace mp4 { | 18 namespace mp4 { |
| 20 | 19 |
| 21 // This class parses the AAC information from decoder specific information | 20 // This class parses the AAC information from decoder specific information |
| 22 // embedded in the esds box in an ISO BMFF file. | 21 // embedded in the esds box in an ISO BMFF file. |
| 23 // Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig | 22 // Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig |
| 24 // for more details. | 23 // for more details. |
| 25 class MEDIA_EXPORT AAC { | 24 class MEDIA_EXPORT AAC { |
| 26 public: | 25 public: |
| 27 AAC(); | 26 AAC(); |
| 28 ~AAC(); | 27 ~AAC(); |
| 29 | 28 |
| 30 // Parse the AAC config from the raw binary data embedded in esds box. | 29 // Parse the AAC config from the raw binary data embedded in esds box. |
| 31 // The function will parse the data and get the ElementaryStreamDescriptor, | 30 // The function will parse the data and get the ElementaryStreamDescriptor, |
| 32 // then it will parse the ElementaryStreamDescriptor to get audio stream | 31 // then it will parse the ElementaryStreamDescriptor to get audio stream |
| 33 // configurations. | 32 // configurations. |
| 34 bool Parse(const std::vector<uint8>& data, | 33 bool Parse(const std::vector<uint8_t>& data, |
| 35 const scoped_refptr<MediaLog>& media_log); | 34 const scoped_refptr<MediaLog>& media_log); |
| 36 | 35 |
| 37 // Gets the output sample rate for the AAC stream. | 36 // Gets the output sample rate for the AAC stream. |
| 38 // |sbr_in_mimetype| should be set to true if the SBR mode is | 37 // |sbr_in_mimetype| should be set to true if the SBR mode is |
| 39 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter). | 38 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter). |
| 40 // Returns the samples_per_second value that should used in an | 39 // Returns the samples_per_second value that should used in an |
| 41 // AudioDecoderConfig. | 40 // AudioDecoderConfig. |
| 42 int GetOutputSamplesPerSecond(bool sbr_in_mimetype) const; | 41 int GetOutputSamplesPerSecond(bool sbr_in_mimetype) const; |
| 43 | 42 |
| 44 // Gets the channel layout for the AAC stream. | 43 // Gets the channel layout for the AAC stream. |
| 45 // |sbr_in_mimetype| should be set to true if the SBR mode is | 44 // |sbr_in_mimetype| should be set to true if the SBR mode is |
| 46 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter). | 45 // signalled in the mimetype. (ie mp4a.40.5 in the codecs parameter). |
| 47 // Returns the channel_layout value that should used in an | 46 // Returns the channel_layout value that should used in an |
| 48 // AudioDecoderConfig. | 47 // AudioDecoderConfig. |
| 49 ChannelLayout GetChannelLayout(bool sbr_in_mimetype) const; | 48 ChannelLayout GetChannelLayout(bool sbr_in_mimetype) const; |
| 50 | 49 |
| 51 // This function converts a raw AAC frame into an AAC frame with an ADTS | 50 // This function converts a raw AAC frame into an AAC frame with an ADTS |
| 52 // header. On success, the function returns true and stores the converted data | 51 // header. On success, the function returns true and stores the converted data |
| 53 // in the buffer. The function returns false on failure and leaves the buffer | 52 // in the buffer. The function returns false on failure and leaves the buffer |
| 54 // unchanged. | 53 // unchanged. |
| 55 bool ConvertEsdsToADTS(std::vector<uint8>* buffer) const; | 54 bool ConvertEsdsToADTS(std::vector<uint8_t>* buffer) const; |
| 56 | 55 |
| 57 #if defined(OS_ANDROID) | 56 #if defined(OS_ANDROID) |
| 58 // Returns the codec specific data needed by android MediaCodec. | 57 // Returns the codec specific data needed by android MediaCodec. |
| 59 std::vector<uint8> codec_specific_data() const { | 58 std::vector<uint8_t> codec_specific_data() const { |
| 60 return codec_specific_data_; | 59 return codec_specific_data_; |
| 61 } | 60 } |
| 62 #endif | 61 #endif |
| 63 | 62 |
| 64 private: | 63 private: |
| 65 bool SkipDecoderGASpecificConfig(BitReader* bit_reader) const; | 64 bool SkipDecoderGASpecificConfig(BitReader* bit_reader) const; |
| 66 bool SkipErrorSpecificConfig() const; | 65 bool SkipErrorSpecificConfig() const; |
| 67 bool SkipGASpecificConfig(BitReader* bit_reader) const; | 66 bool SkipGASpecificConfig(BitReader* bit_reader) const; |
| 68 | 67 |
| 69 // The following variables store the AAC specific configuration information | 68 // The following variables store the AAC specific configuration information |
| 70 // that are used to generate the ADTS header. | 69 // that are used to generate the ADTS header. |
| 71 uint8 profile_; | 70 uint8_t profile_; |
| 72 uint8 frequency_index_; | 71 uint8_t frequency_index_; |
| 73 uint8 channel_config_; | 72 uint8_t channel_config_; |
| 74 | 73 |
| 75 #if defined(OS_ANDROID) | 74 #if defined(OS_ANDROID) |
| 76 // The codec specific data needed by the android MediaCodec. | 75 // The codec specific data needed by the android MediaCodec. |
| 77 std::vector<uint8> codec_specific_data_; | 76 std::vector<uint8_t> codec_specific_data_; |
| 78 #endif | 77 #endif |
| 79 | 78 |
| 80 // The following variables store audio configuration information that | 79 // The following variables store audio configuration information that |
| 81 // can be used by Chromium. They are based on the AAC specific | 80 // can be used by Chromium. They are based on the AAC specific |
| 82 // configuration but can be overridden by extensions in elementary | 81 // configuration but can be overridden by extensions in elementary |
| 83 // stream descriptor. | 82 // stream descriptor. |
| 84 int frequency_; | 83 int frequency_; |
| 85 int extension_frequency_; | 84 int extension_frequency_; |
| 86 ChannelLayout channel_layout_; | 85 ChannelLayout channel_layout_; |
| 87 }; | 86 }; |
| 88 | 87 |
| 89 } // namespace mp4 | 88 } // namespace mp4 |
| 90 | 89 |
| 91 } // namespace media | 90 } // namespace media |
| 92 | 91 |
| 93 #endif // MEDIA_FORMATS_MP4_AAC_H_ | 92 #endif // MEDIA_FORMATS_MP4_AAC_H_ |
| OLD | NEW |