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 VideoCodec {
16  kUnknownVideoCodec = 0,
17  kCodecH264,
18  kCodecHEV1,
19  kCodecHVC1,
20  kCodecVC1,
21  kCodecMPEG2,
22  kCodecMPEG4,
23  kCodecTheora,
24  kCodecVP8,
25  kCodecVP9,
26  kCodecVP10,
27  kNumVideoCodec
28 };
29 
31 class VideoStreamInfo : public StreamInfo {
32  public:
36  VideoStreamInfo(int track_id,
37  uint32_t time_scale,
38  uint64_t duration,
39  VideoCodec codec,
40  const std::string& codec_string,
41  const std::string& language,
42  uint16_t width,
43  uint16_t height,
44  uint32_t pixel_width,
45  uint32_t pixel_height,
46  int16_t trick_play_rate,
47  uint8_t nalu_length_size,
48  const uint8_t* codec_config,
49  size_t codec_config_size,
50  bool is_encrypted);
51 
54  bool IsValidConfig() const override;
55  std::string ToString() const override;
57 
58  VideoCodec codec() const { return codec_; }
59  uint16_t width() const { return width_; }
60  uint16_t height() const { return height_; }
63  uint32_t pixel_width() const { return pixel_width_; }
66  uint32_t pixel_height() const { return pixel_height_; }
67  uint8_t nalu_length_size() const { return nalu_length_size_; }
68  int16_t trick_play_rate() const { return trick_play_rate_; }
69 
70  void set_codec(VideoCodec codec) { codec_ = codec; }
71  void set_width(uint32_t width) { width_ = width; }
72  void set_height(uint32_t height) { height_ = height; }
73  void set_pixel_width(uint32_t pixel_width) { pixel_width_ = pixel_width; }
74  void set_pixel_height(uint32_t pixel_height) { pixel_height_ = pixel_height; }
75 
76  private:
77  ~VideoStreamInfo() override;
78 
79  VideoCodec codec_;
80  uint16_t width_;
81  uint16_t height_;
82 
83  // pixel_width_:pixel_height_ is the sample aspect ratio.
84  // 0 means unknown.
85  uint32_t pixel_width_;
86  uint32_t pixel_height_;
87  int16_t trick_play_rate_; // Non-zero for trick-play streams.
88 
89  // Specifies the normalized size of the NAL unit length field. Can be 1, 2 or
90  // 4 bytes, or 0 if the size if unknown or the stream is not a AVC stream
91  // (H.264).
92  uint8_t nalu_length_size_;
93 
94  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
95  // generated copy constructor and assignment operator. Since the extra data is
96  // typically small, the performance impact is minimal.
97 };
98 
99 } // namespace media
100 } // namespace shaka
101 
102 #endif // MEDIA_BASE_VIDEO_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:26
bool IsValidConfig() const override
VideoStreamInfo(int track_id, uint32_t time_scale, uint64_t duration, VideoCodec codec, const std::string &codec_string, const std::string &language, 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 uint8_t *codec_config, size_t codec_config_size, bool is_encrypted)
Holds video stream information.
std::string ToString() const override