Shaka Packager SDK
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 PACKAGER_MEDIA_CODECS_ES_DESCRIPTOR_H_
6 #define PACKAGER_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 class ObjectType : uint8_t {
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_ == ObjectType::kISO_14496_3 ||
66  object_type_ == ObjectType::kISO_13818_7_AAC_LC;
67  }
68 
69  bool IsDTS() const {
70  return object_type_ == ObjectType::kDTSC ||
71  object_type_ == ObjectType::kDTSE ||
72  object_type_ == ObjectType::kDTSH ||
73  object_type_ == ObjectType::kDTSL;
74  }
75 
76  private:
77  enum Tag {
78  kESDescrTag = 0x03,
79  kDecoderConfigDescrTag = 0x04,
80  kDecoderSpecificInfoTag = 0x05,
81  kSLConfigTag = 0x06,
82  };
83 
84  bool ParseDecoderConfigDescriptor(BitReader* reader);
85  bool ParseDecoderSpecificInfo(BitReader* reader);
86 
87  uint16_t esid_; // Elementary Stream ID.
88  ObjectType object_type_;
89  uint32_t max_bitrate_;
90  uint32_t avg_bitrate_;
91  std::vector<uint8_t> decoder_specific_info_;
92 };
93 
94 } // namespace media
95 } // namespace shaka
96 
97 #endif // PACKAGER_MEDIA_CODECS_ES_DESCRIPTOR_H_
A class to read bit streams.
Definition: bit_reader.h:17
All the methods that are virtual are virtual for mocking.