DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator
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_STREAM_INFO_H_
8 #define MEDIA_BASE_STREAM_INFO_H_
9 
10 #include <string>
11 #include <vector>
12 
13 namespace shaka {
14 namespace media {
15 
16 enum StreamType {
17  kStreamUnknown = 0,
18  kStreamAudio,
19  kStreamVideo,
20  kStreamText,
21 };
22 
23 enum Codec {
24  kUnknownCodec = 0,
25 
26  kCodecVideo = 100,
27  kCodecH264 = kCodecVideo,
28  kCodecHEV1,
29  kCodecHVC1,
30  kCodecVC1,
31  kCodecMPEG2,
32  kCodecMPEG4,
33  kCodecTheora,
34  kCodecVP8,
35  kCodecVP9,
36  kCodecVP10,
37  kCodecVideoMaxPlusOne,
38 
39  kCodecAudio = 200,
40  kCodecAAC = kCodecAudio,
41  kCodecAC3,
42  kCodecDTSC,
43  kCodecDTSE,
44  kCodecDTSH,
45  kCodecDTSL,
46  kCodecDTSM,
47  kCodecDTSP,
48  kCodecEAC3,
49  kCodecOpus,
50  kCodecVorbis,
51  kCodecAudioMaxPlusOne,
52 
53  kCodecText = 300,
54 };
55 
57 class StreamInfo {
58  public:
59  StreamInfo(StreamType stream_type, int track_id, uint32_t time_scale,
60  uint64_t duration, Codec codec, const std::string& codec_string,
61  const uint8_t* codec_config, size_t codec_config_size,
62  const std::string& language, bool is_encrypted);
63 
64  virtual ~StreamInfo();
65 
68  virtual bool IsValidConfig() const = 0;
69 
71  virtual std::string ToString() const;
72 
73  StreamType stream_type() const { return stream_type_; }
74  uint32_t track_id() const { return track_id_; }
75  uint32_t time_scale() const { return time_scale_; }
76  uint64_t duration() const { return duration_; }
77  Codec codec() const { return codec_; }
78  const std::string& codec_string() const { return codec_string_; }
79  const std::vector<uint8_t>& codec_config() const { return codec_config_; }
80  const std::string& language() const { return language_; }
81  bool is_encrypted() const { return is_encrypted_; }
82 
83  void set_duration(int duration) { duration_ = duration; }
84  void set_codec(Codec codec) { codec_ = codec; }
85  void set_codec_config(const std::vector<uint8_t>& data) { codec_config_ = data; }
86  void set_codec_string(const std::string& codec_string) {
87  codec_string_ = codec_string;
88  }
89  void set_language(const std::string& language) { language_ = language; }
90  void set_is_encrypted(bool is_encrypted) { is_encrypted_ = is_encrypted; }
91 
92  private:
93  // Whether the stream is Audio or Video.
94  StreamType stream_type_;
95  uint32_t track_id_;
96  // The actual time is calculated as time / time_scale_ in seconds.
97  uint32_t time_scale_;
98  // Duration base on time_scale.
99  uint64_t duration_;
100  Codec codec_;
101  std::string codec_string_;
102  std::string language_;
103  // Whether the stream is potentially encrypted.
104  // Note that in a potentially encrypted stream, individual buffers
105  // can be encrypted or not encrypted.
106  bool is_encrypted_;
107  // Optional byte data required for some audio/video decoders such as Vorbis
108  // codebooks.
109  std::vector<uint8_t> codec_config_;
110 
111  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
112  // generated copy constructor and assignment operator. Since the extra data is
113  // typically small, the performance impact is minimal.
114 };
115 
116 } // namespace media
117 } // namespace shaka
118 
119 #endif // MEDIA_BASE_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:57
virtual bool IsValidConfig() const =0
virtual std::string ToString() const
Definition: stream_info.cc:37