DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs 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 edash_packager {
13 namespace media {
14 
15 enum VideoCodec {
16  kUnknownVideoCodec = 0,
17  kCodecH264,
18  kCodecVC1,
19  kCodecMPEG2,
20  kCodecMPEG4,
21  kCodecTheora,
22  kCodecVP8,
23  kCodecVP9,
24  kNumVideoCodec
25 };
26 
28 class VideoStreamInfo : public StreamInfo {
29  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* extra_data,
49  size_t extra_data_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_width(uint32_t width) { width_ = width; }
71  void set_height(uint32_t height) { height_ = height; }
72  void set_pixel_width(uint32_t pixel_width) { pixel_width_ = pixel_width; }
73  void set_pixel_height(uint32_t pixel_height) { pixel_height_ = pixel_height; }
74 
77  static std::string GetCodecString(VideoCodec codec,
78  uint8_t profile,
79  uint8_t compatible_profiles,
80  uint8_t level);
81 
82  private:
83  ~VideoStreamInfo() override;
84 
85  VideoCodec codec_;
86  uint16_t width_;
87  uint16_t height_;
88 
89  // pixel_width_:pixel_height_ is the sample aspect ratio.
90  // 0 means unknown.
91  uint32_t pixel_width_;
92  uint32_t pixel_height_;
93  int16_t trick_play_rate_; // Non-zero for trick-play streams.
94 
95  // Specifies the normalized size of the NAL unit length field. Can be 1, 2 or
96  // 4 bytes, or 0 if the size if unknown or the stream is not a AVC stream
97  // (H.264).
98  uint8_t nalu_length_size_;
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 edash_packager
107 
108 #endif // MEDIA_BASE_VIDEO_STREAM_INFO_H_
std::string ToString() const override
Abstract class holds stream information.
Definition: stream_info.h:26
static std::string GetCodecString(VideoCodec codec, uint8_t profile, uint8_t compatible_profiles, uint8_t level)
Holds video stream information.
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 *extra_data, size_t extra_data_size, bool is_encrypted)