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