DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
vp_codec_configuration.h
1 // Copyright 2015 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_VP_CODEC_CONFIGURATION_H_
8 #define MEDIA_FILTERS_VP_CODEC_CONFIGURATION_H_
9 
10 #include <stdint.h>
11 #include <string>
12 #include <vector>
13 
14 #include "packager/base/macros.h"
15 #include "packager/media/base/video_stream_info.h"
16 
17 namespace shaka {
18 namespace media {
19 
22  public:
23  enum ColorSpace {
24  COLOR_SPACE_UNSPECIFIED = 0,
25  COLOR_SPACE_BT_601 = 1,
26  COLOR_SPACE_BT_709 = 2,
27  COLOR_SPACE_SMPTE_170 = 3,
28  COLOR_SPACE_SMPTE_240 = 4,
29  COLOR_SPACE_BT_2020_NON_CONSTANT_LUMINANCE = 5,
30  COLOR_SPACE_BT_2020_CONSTANT_LUMINANCE = 6,
31  COLOR_SPACE_SRGB = 7,
32  };
33 
34  enum ChromaSubsampling {
35  CHROMA_420_VERTICAL = 0,
36  CHROMA_420_COLLOCATED_WITH_LUMA = 1,
37  CHROMA_422 = 2,
38  CHROMA_444 = 3,
39  CHROMA_440 = 4,
40  };
41 
43  VPCodecConfiguration(uint8_t profile,
44  uint8_t level,
45  uint8_t bit_depth,
46  uint8_t color_space,
47  uint8_t chroma_subsampling,
48  uint8_t transfer_function,
49  bool video_full_range_flag,
50  const std::vector<uint8_t>& codec_initialization_data);
52 
55  bool Parse(const std::vector<uint8_t>& data);
56 
59  void Write(std::vector<uint8_t>* data) const;
60 
62  std::string GetCodecString(VideoCodec codec) const;
63 
64  void set_profile(uint8_t profile) { profile_ = profile; }
65  void set_level(uint8_t level) { level_ = level; }
66  void set_bit_depth(uint8_t bit_depth) { bit_depth_ = bit_depth; }
67  void set_color_space(uint8_t color_space) { color_space_ = color_space; }
68  void set_chroma_subsampling(uint8_t chroma_subsampling) {
69  chroma_subsampling_ = chroma_subsampling;
70  }
71  void set_transfer_function(uint8_t transfer_function) {
72  transfer_function_ = transfer_function;
73  }
74  void set_video_full_range_flag(bool video_full_range_flag) {
75  video_full_range_flag_ = video_full_range_flag;
76  }
77 
78  uint8_t profile() const { return profile_; }
79  uint8_t level() const { return level_; }
80  uint8_t bit_depth() const { return bit_depth_; }
81  uint8_t color_space() const { return color_space_; }
82  uint8_t chroma_subsampling() const { return chroma_subsampling_; }
83  uint8_t transfer_function() const { return transfer_function_; }
84  bool video_full_range_flag() const { return video_full_range_flag_; }
85 
86  private:
87  uint8_t profile_;
88  uint8_t level_;
89  uint8_t bit_depth_;
90  uint8_t color_space_;
91  uint8_t chroma_subsampling_;
92  uint8_t transfer_function_;
93  bool video_full_range_flag_;
94  std::vector<uint8_t> codec_initialization_data_;
95 
96  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
97  // generated copy constructor and assignment operator. Since the internal data
98  // is small, the performance impact is minimal.
99 };
100 
101 } // namespace media
102 } // namespace shaka
103 
104 #endif // MEDIA_FILTERS_VP_CODEC_CONFIGURATION_H_
void Write(std::vector< uint8_t > *data) const
bool Parse(const std::vector< uint8_t > &data)
std::string GetCodecString(VideoCodec codec) const
Class for parsing or writing VP codec configuration data.