DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
decoder_configuration.h
1 // Copyright 2016 Google Inc. All rights reserved.
2 //
3 // Use of this source code is governed by a BSD-style
4 // license that can be found in the LICENSE file or at
5 // https://developers.google.com/open-source/licenses/bsd
6 
7 #ifndef MEDIA_FILTERS_DECODER_CONFIGURATION_H_
8 #define MEDIA_FILTERS_DECODER_CONFIGURATION_H_
9 
10 #include <vector>
11 
12 #include "packager/base/logging.h"
13 #include "packager/base/macros.h"
14 #include "packager/media/filters/nalu_reader.h"
15 
16 namespace shaka {
17 namespace media {
18 
19 // Defines a base class for decoder configurations.
21  public:
22  virtual ~DecoderConfiguration();
23 
27  bool Parse(const std::vector<uint8_t>& data) {
28  return Parse(data.data(), data.size());
29  }
30 
34  bool Parse(const uint8_t* data, size_t data_size);
35 
37  uint8_t nalu_length_size() const { return nalu_length_size_; }
38 
40  size_t nalu_count() const { return nalu_.size(); }
41 
44  const Nalu& nalu(size_t i) const { return nalu_[i]; }
45 
46  protected:
48 
50  void AddNalu(const Nalu& nalu);
51 
53  const uint8_t* data() const { return data_.data(); }
54 
56  size_t data_size() const { return data_.size(); }
57 
60  DCHECK(nalu_length_size <= 2 || nalu_length_size == 4);
61  nalu_length_size_ = nalu_length_size;
62  }
63 
64  private:
65  // Performs the actual parsing of the data.
66  virtual bool ParseInternal() = 0;
67 
68  // Contains a copy of the data. This manages the pointer lifetime so the
69  // extracted Nalu can accessed.
70  std::vector<uint8_t> data_;
71  std::vector<Nalu> nalu_;
72  uint8_t nalu_length_size_;
73 
74  DISALLOW_COPY_AND_ASSIGN(DecoderConfiguration);
75 };
76 
77 } // namespace media
78 } // namespace shaka
79 
80 #endif // MEDIA_FILTERS_DECODER_CONFIGURATION_H_
bool Parse(const std::vector< uint8_t > &data)
void AddNalu(const Nalu &nalu)
Adds the given Nalu to the configuration.
void set_nalu_length_size(uint8_t nalu_length_size)
Sets the size of the NAL unit length field.
const Nalu & nalu(size_t i) const