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:
28  VideoStreamInfo(int track_id,
29  uint32_t time_scale,
30  uint64_t duration,
31  Codec codec,
32  H26xStreamFormat h26x_stream_format,
33  const std::string& codec_string,
34  const uint8_t* codec_config,
35  size_t codec_config_size,
36  uint16_t width,
37  uint16_t height,
38  uint32_t pixel_width,
39  uint32_t pixel_height,
40  int16_t trick_play_rate,
41  uint8_t nalu_length_size,
42  const std::string& language,
43  bool is_encrypted);
44 
45  ~VideoStreamInfo() override;
46 
49  bool IsValidConfig() const override;
50  std::string ToString() const override;
52 
53  H26xStreamFormat h26x_stream_format() const { return h26x_stream_format_; }
54  uint16_t width() const { return width_; }
55  uint16_t height() const { return height_; }
58  uint32_t pixel_width() const { return pixel_width_; }
61  uint32_t pixel_height() const { return pixel_height_; }
62  uint8_t nalu_length_size() const { return nalu_length_size_; }
63  int16_t trick_play_rate() const { return trick_play_rate_; }
64  const std::vector<uint8_t>& eme_init_data() const { return eme_init_data_; }
65 
66  void set_width(uint32_t width) { width_ = width; }
67  void set_height(uint32_t height) { height_ = height; }
68  void set_pixel_width(uint32_t pixel_width) { pixel_width_ = pixel_width; }
69  void set_pixel_height(uint32_t pixel_height) { pixel_height_ = pixel_height; }
70  void set_eme_init_data(const uint8_t* eme_init_data,
71  size_t eme_init_data_size) {
72  eme_init_data_.assign(eme_init_data, eme_init_data + eme_init_data_size);
73  }
74 
75  private:
76  H26xStreamFormat h26x_stream_format_;
77  uint16_t width_;
78  uint16_t height_;
79 
80  // pixel_width_:pixel_height_ is the sample aspect ratio.
81  // 0 means unknown.
82  uint32_t pixel_width_;
83  uint32_t pixel_height_;
84  int16_t trick_play_rate_; // Non-zero for trick-play streams.
85 
86  // Specifies the size of the NAL unit length field. Can be 1, 2 or 4 bytes, or
87  // 0 if the stream is not a NAL structured video stream or if it is an AnnexB
88  // byte stream.
89  uint8_t nalu_length_size_;
90 
91  // Container-specific data used by CDM to generate a license request:
92  // https://w3c.github.io/encrypted-media/#initialization-data.
93  std::vector<uint8_t> eme_init_data_;
94 
95  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
96  // generated copy constructor and assignment operator. Since the extra data is
97  // typically small, the performance impact is minimal.
98 };
99 
100 } // namespace media
101 } // namespace shaka
102 
103 #endif // MEDIA_BASE_VIDEO_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:57
bool IsValidConfig() const override
VideoStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, Codec codec, H26xStreamFormat h26x_stream_format, const std::string &codec_string, const uint8_t *codec_config, size_t codec_config_size, uint16_t width, uint16_t height, uint32_t pixel_width, uint32_t pixel_height, int16_t trick_play_rate, uint8_t nalu_length_size, const std::string &language, bool is_encrypted)
Holds video stream information.
std::string ToString() const override