DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs 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 edash_packager {
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 };
28 
32 class ESDescriptor {
33  public:
34  ESDescriptor();
35  ~ESDescriptor();
36 
37  bool Parse(const std::vector<uint8_t>& data);
38  void Write(BufferWriter* writer) const;
39  size_t ComputeSize() const;
40 
41  uint16_t esid() const { return esid_; }
42  void set_esid(uint16_t esid) { esid_ = esid; }
43 
44  ObjectType object_type() const { return object_type_; }
45  void set_object_type(ObjectType object_type) { object_type_ = object_type; }
46 
47  const std::vector<uint8_t>& decoder_specific_info() const {
48  return decoder_specific_info_;
49  }
50  void set_decoder_specific_info(
51  const std::vector<uint8_t>& decoder_specific_info) {
52  decoder_specific_info_ = decoder_specific_info;
53  }
54 
56  bool IsAAC() const {
57  return object_type_ == kISO_14496_3 || object_type_ == kISO_13818_7_AAC_LC;
58  }
59 
60  private:
61  enum Tag {
62  kESDescrTag = 0x03,
63  kDecoderConfigDescrTag = 0x04,
64  kDecoderSpecificInfoTag = 0x05,
65  kSLConfigTag = 0x06,
66  };
67 
68  bool ParseDecoderConfigDescriptor(BitReader* reader);
69  bool ParseDecoderSpecificInfo(BitReader* reader);
70 
71  uint16_t esid_; // Elementary Stream ID.
72  ObjectType object_type_;
73  std::vector<uint8_t> decoder_specific_info_;
74 };
75 
76 } // namespace mp4
77 
78 } // namespace media
79 } // namespace edash_packager
80 
81 #endif // MEDIA_FORMATS_MP4_ES_DESCRIPTOR_H_
A class to read bit streams.
Definition: bit_reader.h:17