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