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