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