Shaka Packager SDK
nal_unit_to_byte_stream_converter.h
1 // Copyright 2016 Google LLC. 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 PACKAGER_MEDIA_CODECS_NAL_UNIT_TO_BYTE_STREAM_CONVERTER_H_
8 #define PACKAGER_MEDIA_CODECS_NAL_UNIT_TO_BYTE_STREAM_CONVERTER_H_
9 
10 #include <cstdint>
11 #include <vector>
12 
13 #include <packager/macros/classes.h>
14 #include <packager/media/base/decrypt_config.h>
15 #include <packager/media/codecs/avc_decoder_configuration_record.h>
16 
17 namespace shaka {
18 namespace media {
19 
20 class BufferWriter;
21 class VideoStreamInfo;
22 
30 void EscapeNalByteSequence(const uint8_t* input,
31  size_t input_size,
32  BufferWriter* output);
33 
34 // Methods are virtual for mocking.
36  public:
39 
45  virtual bool Initialize(const uint8_t* decoder_configuration_data,
46  size_t decoder_configuration_data_size);
47 
56  virtual bool ConvertUnitToByteStream(const uint8_t* sample,
57  size_t sample_size,
58  bool is_key_frame,
59  std::vector<uint8_t>* output);
60 
76  const uint8_t* sample,
77  size_t sample_size,
78  bool is_key_frame,
79  bool escape_encrypted_nalu,
80  std::vector<uint8_t>* output,
81  std::vector<SubsampleEntry>* subsamples);
82 
83  private:
84  friend class NalUnitToByteStreamConverterTest;
85 
86  int nalu_length_size_;
87  AVCDecoderConfigurationRecord decoder_config_;
88  std::vector<uint8_t> decoder_configuration_in_byte_stream_;
89 
90  DISALLOW_COPY_AND_ASSIGN(NalUnitToByteStreamConverter);
91 };
92 
93 } // namespace media
94 } // namespace shaka
95 
96 #endif // PACKAGER_MEDIA_CODECS_NAL_UNIT_TO_BYTE_STREAM_CONVERTER_H_
Class for parsing AVC decoder configuration record.
virtual bool Initialize(const uint8_t *decoder_configuration_data, size_t decoder_configuration_data_size)
virtual bool ConvertUnitToByteStream(const uint8_t *sample, size_t sample_size, bool is_key_frame, std::vector< uint8_t > *output)
virtual bool ConvertUnitToByteStreamWithSubsamples(const uint8_t *sample, size_t sample_size, bool is_key_frame, bool escape_encrypted_nalu, std::vector< uint8_t > *output, std::vector< SubsampleEntry > *subsamples)
All the methods that are virtual are virtual for mocking.
Definition: crypto_flags.cc:66