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