2013-09-24 01:35:40 +00:00
|
|
|
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
2016-05-25 18:03:17 +00:00
|
|
|
#ifndef MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
|
|
|
#define MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <stddef.h>
|
|
|
|
#include <stdint.h>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-09-30 23:52:58 +00:00
|
|
|
#include <vector>
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2013-09-24 01:35:40 +00:00
|
|
|
namespace media {
|
|
|
|
|
|
|
|
class BitReader;
|
|
|
|
|
2016-03-16 19:10:12 +00:00
|
|
|
// Methods are virtual for mocking.
|
2014-01-23 22:34:39 +00:00
|
|
|
/// This class parses the AAC information from decoder specific information
|
|
|
|
/// embedded in the @b esds box in an ISO BMFF file.
|
|
|
|
/// Please refer to ISO 14496 Part 3 Table 1.13 - Syntax of AudioSpecificConfig
|
|
|
|
/// for more details.
|
2014-01-10 00:21:06 +00:00
|
|
|
class AACAudioSpecificConfig {
|
2013-09-24 01:35:40 +00:00
|
|
|
public:
|
2014-01-10 00:21:06 +00:00
|
|
|
AACAudioSpecificConfig();
|
2016-03-16 19:10:12 +00:00
|
|
|
virtual ~AACAudioSpecificConfig();
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Parse the AAC config from decoder specific information embedded in an @b
|
|
|
|
/// esds box. The function will parse the data and get the
|
|
|
|
/// ElementaryStreamDescriptor, then it will parse the
|
|
|
|
/// ElementaryStreamDescriptor to get audio stream configurations.
|
|
|
|
/// @param data contains decoder specific information from an @b esds box.
|
|
|
|
/// @return true if successful, false otherwise.
|
2016-03-16 19:10:12 +00:00
|
|
|
virtual bool Parse(const std::vector<uint8_t>& data);
|
|
|
|
|
|
|
|
/// Convert a raw AAC frame into an AAC frame with an ADTS header.
|
|
|
|
/// @param[in,out] buffer contains the raw AAC frame on input, and the
|
|
|
|
/// converted frame on output if successful; it is untouched
|
|
|
|
/// on failure.
|
|
|
|
/// @return true on success, false otherwise.
|
|
|
|
virtual bool ConvertToADTS(std::vector<uint8_t>* buffer) const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @param sbr_in_mimetype indicates whether SBR mode is specified in the
|
|
|
|
/// mimetype, i.e. codecs parameter contains mp4a.40.5.
|
|
|
|
/// @return Output sample rate for the AAC stream.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t GetOutputSamplesPerSecond(bool sbr_in_mimetype) const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @param sbr_in_mimetype indicates whether SBR mode is specified in the
|
|
|
|
/// mimetype, i.e. codecs parameter contains mp4a.40.5.
|
|
|
|
/// @return Number of channels for the AAC stream.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t GetNumChannels(bool sbr_in_mimetype) const;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return The audio object type for this AAC config.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t audio_object_type() const { return audio_object_type_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return The sampling frequency for this AAC config.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t frequency() const { return frequency_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return Number of channels for this AAC config.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t num_channels() const { return num_channels_; }
|
2013-10-14 20:55:48 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// Size in bytes of the ADTS header added by ConvertEsdsToADTS().
|
2013-09-24 01:35:40 +00:00
|
|
|
static const size_t kADTSHeaderSize = 7;
|
|
|
|
|
|
|
|
private:
|
|
|
|
bool SkipDecoderGASpecificConfig(BitReader* bit_reader) const;
|
|
|
|
bool SkipErrorSpecificConfig() const;
|
|
|
|
bool SkipGASpecificConfig(BitReader* bit_reader) const;
|
|
|
|
|
|
|
|
// The following variables store the AAC specific configuration information
|
|
|
|
// that are used to generate the ADTS header.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t audio_object_type_;
|
|
|
|
uint8_t frequency_index_;
|
|
|
|
uint8_t channel_config_;
|
2013-10-14 20:55:48 +00:00
|
|
|
// Is Parametric Stereo on?
|
|
|
|
bool ps_present_;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2013-09-24 04:17:12 +00:00
|
|
|
// The following variables store audio configuration information.
|
|
|
|
// They are based on the AAC specific configuration but can be overridden
|
|
|
|
// by extensions in elementary stream descriptor.
|
2014-09-30 21:52:21 +00:00
|
|
|
uint32_t frequency_;
|
|
|
|
uint32_t extension_frequency_;
|
|
|
|
uint8_t num_channels_;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-05-25 18:03:17 +00:00
|
|
|
#endif // MEDIA_CODECS_AAC_AUDIO_SPECIFIC_CONFIG_H_
|