DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
video_stream_info.h
1 // Copyright 2014 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_BASE_VIDEO_STREAM_INFO_H_
8 #define MEDIA_BASE_VIDEO_STREAM_INFO_H_
9 
10 #include "packager/media/base/stream_info.h"
11 
12 namespace shaka {
13 namespace media {
14 
15 enum class H26xStreamFormat {
16  kUnSpecified,
17  kAnnexbByteStream,
18  kNalUnitStreamWithParameterSetNalus,
19  kNalUnitStreamWithoutParameterSetNalus,
20 };
21 
23 class VideoStreamInfo : public StreamInfo {
24  public:
25  VideoStreamInfo() = default;
26 
30  VideoStreamInfo(int track_id,
31  uint32_t time_scale,
32  uint64_t duration,
33  Codec codec,
34  H26xStreamFormat h26x_stream_format,
35  const std::string& codec_string,
36  const uint8_t* codec_config,
37  size_t codec_config_size,
38  uint16_t width,
39  uint16_t height,
40  uint32_t pixel_width,
41  uint32_t pixel_height,
42  int16_t trick_play_rate,
43  uint8_t nalu_length_size,
44  const std::string& language,
45  bool is_encrypted);
46 
47  ~VideoStreamInfo() override;
48 
51  bool IsValidConfig() const override;
52  std::string ToString() const override;
54 
55  H26xStreamFormat h26x_stream_format() const { return h26x_stream_format_; }
56  uint16_t width() const { return width_; }
57  uint16_t height() const { return height_; }
60  uint32_t pixel_width() const { return pixel_width_; }
63  uint32_t pixel_height() const { return pixel_height_; }
64  uint8_t nalu_length_size() const { return nalu_length_size_; }
65  int16_t trick_play_rate() const { return trick_play_rate_; }
66  const std::vector<uint8_t>& eme_init_data() const { return eme_init_data_; }
67 
68  void set_width(uint32_t width) { width_ = width; }
69  void set_height(uint32_t height) { height_ = height; }
70  void set_pixel_width(uint32_t pixel_width) { pixel_width_ = pixel_width; }
71  void set_pixel_height(uint32_t pixel_height) { pixel_height_ = pixel_height; }
72  void set_trick_play_rate(int16_t trick_play_rate) {
73  trick_play_rate_ = trick_play_rate;
74  }
75  void set_eme_init_data(const uint8_t* eme_init_data,
76  size_t eme_init_data_size) {
77  eme_init_data_.assign(eme_init_data, eme_init_data + eme_init_data_size);
78  }
79 
80  private:
81  H26xStreamFormat h26x_stream_format_;
82  uint16_t width_;
83  uint16_t height_;
84 
85  // pixel_width_:pixel_height_ is the sample aspect ratio.
86  // 0 means unknown.
87  uint32_t pixel_width_;
88  uint32_t pixel_height_;
89  int16_t trick_play_rate_; // Non-zero for trick-play streams.
90 
91  // Specifies the size of the NAL unit length field. Can be 1, 2 or 4 bytes, or
92  // 0 if the stream is not a NAL structured video stream or if it is an AnnexB
93  // byte stream.
94  uint8_t nalu_length_size_;
95 
96  // Container-specific data used by CDM to generate a license request:
97  // https://w3c.github.io/encrypted-media/#initialization-data.
98  std::vector<uint8_t> eme_init_data_;
99 
100  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
101  // generated copy constructor and assignment operator. Since the extra data is
102  // typically small, the performance impact is minimal.
103 };
104 
105 } // namespace media
106 } // namespace shaka
107 
108 #endif // MEDIA_BASE_VIDEO_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:57
bool IsValidConfig() const override
Holds video stream information.
std::string ToString() const override