DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
es_descriptor.h
1 // Copyright (c) 2012 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.
4 
5 #ifndef MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
6 #define MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
7 
8 #include <stddef.h>
9 #include <stdint.h>
10 
11 #include <vector>
12 
13 namespace shaka {
14 namespace media {
15 
16 class BitReader;
17 class BufferWriter;
18 
19 namespace mp4 {
20 
21 // The following values are extracted from ISO 14496 Part 1 Table 5 -
22 // objectTypeIndication Values. Only values currently in use are included.
23 enum ObjectType {
24  kForbidden = 0,
25  kISO_14496_3 = 0x40, // MPEG4 AAC
26  kISO_13818_7_AAC_LC = 0x67, // MPEG2 AAC-LC
27  kDTSC = 0xA9, // DTS Coherent Acoustics audio
28  kDTSE = 0xAC, // DTS Express low bit rate audio
29  kDTSH = 0xAA, // DTS-HD High Resolution Audio
30  kDTSL = 0xAB, // DTS-HD Master Audio
31 };
32 
36 class ESDescriptor {
37  public:
38  ESDescriptor();
39  ~ESDescriptor();
40 
41  bool Parse(const std::vector<uint8_t>& data);
42  void Write(BufferWriter* writer) const;
43  size_t ComputeSize() const;
44 
45  uint16_t esid() const { return esid_; }
46  void set_esid(uint16_t esid) { esid_ = esid; }
47 
48  uint32_t max_bitrate() const {return max_bitrate_; }
49  void set_max_bitrate(uint32_t max_bitrate) { max_bitrate_ = max_bitrate; }
50 
51  uint32_t avg_bitrate() const { return avg_bitrate_; }
52  void set_avg_bitrate(uint32_t avg_bitrate) { avg_bitrate_ = avg_bitrate; }
53 
54  ObjectType object_type() const { return object_type_; }
55  void set_object_type(ObjectType object_type) { object_type_ = object_type; }
56 
57  const std::vector<uint8_t>& decoder_specific_info() const {
58  return decoder_specific_info_;
59  }
60  void set_decoder_specific_info(
61  const std::vector<uint8_t>& decoder_specific_info) {
62  decoder_specific_info_ = decoder_specific_info;
63  }
64 
66  bool IsAAC() const {
67  return object_type_ == kISO_14496_3 || object_type_ == kISO_13818_7_AAC_LC;
68  }
69 
70  bool IsDTS() const {
71  return object_type_ == kDTSC || object_type_ == kDTSE ||
72  object_type_ == kDTSH || object_type_ == kDTSL;
73  }
74 
75  private:
76  enum Tag {
77  kESDescrTag = 0x03,
78  kDecoderConfigDescrTag = 0x04,
79  kDecoderSpecificInfoTag = 0x05,
80  kSLConfigTag = 0x06,
81  };
82 
83  bool ParseDecoderConfigDescriptor(BitReader* reader);
84  bool ParseDecoderSpecificInfo(BitReader* reader);
85 
86  uint16_t esid_; // Elementary Stream ID.
87  ObjectType object_type_;
88  uint32_t max_bitrate_;
89  uint32_t avg_bitrate_;
90  std::vector<uint8_t> decoder_specific_info_;
91 };
92 
93 } // namespace mp4
94 
95 } // namespace media
96 } // namespace shaka
97 
98 #endif // MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_