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.
|
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#ifndef PACKAGER_MEDIA_CODECS_ES_DESCRIPTOR_H_
|
|
|
|
#define PACKAGER_MEDIA_CODECS_ES_DESCRIPTOR_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;
|
2013-11-27 02:23:30 +00:00
|
|
|
class BufferWriter;
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
// The following values are extracted from ISO 14496 Part 1 Table 5 -
|
|
|
|
// objectTypeIndication Values. Only values currently in use are included.
|
|
|
|
enum ObjectType {
|
|
|
|
kForbidden = 0,
|
2013-11-27 02:23:30 +00:00
|
|
|
kISO_14496_3 = 0x40, // MPEG4 AAC
|
2013-09-24 01:35:40 +00:00
|
|
|
kISO_13818_7_AAC_LC = 0x67, // MPEG2 AAC-LC
|
2016-01-04 18:57:05 +00:00
|
|
|
kDTSC = 0xA9, // DTS Coherent Acoustics audio
|
|
|
|
kDTSE = 0xAC, // DTS Express low bit rate audio
|
|
|
|
kDTSH = 0xAA, // DTS-HD High Resolution Audio
|
|
|
|
kDTSL = 0xAB, // DTS-HD Master Audio
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// This class parses object type and decoder specific information from an
|
|
|
|
/// elementary stream descriptor, which is usually contained in an esds
|
|
|
|
/// box. Please refer to ISO 14496 Part 1 7.2.6.5 for more details.
|
2013-09-24 04:17:12 +00:00
|
|
|
class ESDescriptor {
|
2013-09-24 01:35:40 +00:00
|
|
|
public:
|
|
|
|
ESDescriptor();
|
|
|
|
~ESDescriptor();
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
bool Parse(const std::vector<uint8_t>& data);
|
2013-11-27 02:23:30 +00:00
|
|
|
void Write(BufferWriter* writer) const;
|
|
|
|
size_t ComputeSize() const;
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t esid() const { return esid_; }
|
|
|
|
void set_esid(uint16_t esid) { esid_ = esid; }
|
2013-11-27 02:23:30 +00:00
|
|
|
|
2016-01-04 18:57:05 +00:00
|
|
|
uint32_t max_bitrate() const {return max_bitrate_; }
|
|
|
|
void set_max_bitrate(uint32_t max_bitrate) { max_bitrate_ = max_bitrate; }
|
|
|
|
|
|
|
|
uint32_t avg_bitrate() const { return avg_bitrate_; }
|
|
|
|
void set_avg_bitrate(uint32_t avg_bitrate) { avg_bitrate_ = avg_bitrate; }
|
|
|
|
|
2013-11-27 02:23:30 +00:00
|
|
|
ObjectType object_type() const { return object_type_; }
|
|
|
|
void set_object_type(ObjectType object_type) { object_type_ = object_type; }
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
const std::vector<uint8_t>& decoder_specific_info() const {
|
2013-11-27 02:23:30 +00:00
|
|
|
return decoder_specific_info_;
|
|
|
|
}
|
|
|
|
void set_decoder_specific_info(
|
2014-09-30 21:52:21 +00:00
|
|
|
const std::vector<uint8_t>& decoder_specific_info) {
|
2013-11-27 02:23:30 +00:00
|
|
|
decoder_specific_info_ = decoder_specific_info;
|
|
|
|
}
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-01-23 22:34:39 +00:00
|
|
|
/// @return true if the stream is AAC.
|
2013-11-27 02:23:30 +00:00
|
|
|
bool IsAAC() const {
|
|
|
|
return object_type_ == kISO_14496_3 || object_type_ == kISO_13818_7_AAC_LC;
|
|
|
|
}
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2016-01-04 18:57:05 +00:00
|
|
|
bool IsDTS() const {
|
|
|
|
return object_type_ == kDTSC || object_type_ == kDTSE ||
|
|
|
|
object_type_ == kDTSH || object_type_ == kDTSL;
|
|
|
|
}
|
|
|
|
|
2013-09-24 01:35:40 +00:00
|
|
|
private:
|
|
|
|
enum Tag {
|
|
|
|
kESDescrTag = 0x03,
|
|
|
|
kDecoderConfigDescrTag = 0x04,
|
2013-11-27 02:23:30 +00:00
|
|
|
kDecoderSpecificInfoTag = 0x05,
|
|
|
|
kSLConfigTag = 0x06,
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool ParseDecoderConfigDescriptor(BitReader* reader);
|
|
|
|
bool ParseDecoderSpecificInfo(BitReader* reader);
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
uint16_t esid_; // Elementary Stream ID.
|
2013-09-24 04:17:12 +00:00
|
|
|
ObjectType object_type_;
|
2016-01-04 18:57:05 +00:00
|
|
|
uint32_t max_bitrate_;
|
|
|
|
uint32_t avg_bitrate_;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> decoder_specific_info_;
|
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
|
|
|
|
2017-12-20 00:56:36 +00:00
|
|
|
#endif // PACKAGER_MEDIA_CODECS_ES_DESCRIPTOR_H_
|