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.
|
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#ifndef MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
|
|
|
|
#define MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
|
2013-09-24 01:35:40 +00:00
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
|
|
|
|
2014-09-19 20:41:13 +00:00
|
|
|
namespace edash_packager {
|
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
|
|
|
|
|
|
|
namespace mp4 {
|
|
|
|
|
|
|
|
// 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
|
2013-11-27 02:23:30 +00:00
|
|
|
kEAC3 = 0xa6 // Dolby Digital Plus
|
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
|
|
|
|
|
|
|
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
|
|
|
|
|
|
|
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_;
|
2014-09-30 21:52:21 +00:00
|
|
|
std::vector<uint8_t> decoder_specific_info_;
|
2013-09-24 01:35:40 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mp4
|
|
|
|
|
|
|
|
} // namespace media
|
2014-09-19 20:41:13 +00:00
|
|
|
} // namespace edash_packager
|
2013-09-24 01:35:40 +00:00
|
|
|
|
2014-04-10 21:42:38 +00:00
|
|
|
#endif // MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
|