DASH Media Packaging SDK
 All Classes Namespaces Functions Variables Typedefs
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 edash_packager {
16 namespace media {
17 
18 enum StreamType {
19  kStreamUnknown = 0,
20  kStreamAudio,
21  kStreamVideo,
22 };
23 
25 class StreamInfo : public base::RefCountedThreadSafe<StreamInfo> {
26  public:
27  StreamInfo(StreamType stream_type,
28  int track_id,
29  uint32_t time_scale,
30  uint64_t duration,
31  const std::string& codec_string,
32  const std::string& language,
33  const uint8_t* extra_data,
34  size_t extra_data_size,
35  bool is_encrypted);
36 
39  virtual bool IsValidConfig() const = 0;
40 
42  virtual std::string ToString() const;
43 
44  StreamType stream_type() const { return stream_type_; }
45  uint32_t track_id() const { return track_id_; }
46  uint32_t time_scale() const { return time_scale_; }
47  uint64_t duration() const { return duration_; }
48  const std::string& codec_string() const { return codec_string_; }
49  const std::string& language() const { return language_; }
50 
51  bool is_encrypted() const { return is_encrypted_; }
52 
53  const std::vector<uint8_t>& extra_data() const { return extra_data_; }
54 
55  void set_duration(int duration) { duration_ = duration; }
56 
57  void set_extra_data(const std::vector<uint8_t>& data) { extra_data_ = data; }
58 
59  void set_codec_string(const std::string& codec_string) {
60  codec_string_ = codec_string;
61  }
62 
63  void set_language(const std::string& language) { language_ = language; }
64 
65  protected:
66  friend class base::RefCountedThreadSafe<StreamInfo>;
67  virtual ~StreamInfo();
68 
69  private:
70  // Whether the stream is Audio or Video.
71  StreamType stream_type_;
72  uint32_t track_id_;
73  // The actual time is calculated as time / time_scale_ in seconds.
74  uint32_t time_scale_;
75  // Duration base on time_scale.
76  uint64_t duration_;
77  std::string codec_string_;
78  std::string language_;
79  // Whether the stream is potentially encrypted.
80  // Note that in a potentially encrypted stream, individual buffers
81  // can be encrypted or not encrypted.
82  bool is_encrypted_;
83  // Optional byte data required for some audio/video decoders such as Vorbis
84  // codebooks.
85  std::vector<uint8_t> extra_data_;
86 
87  // Not using DISALLOW_COPY_AND_ASSIGN here intentionally to allow the compiler
88  // generated copy constructor and assignment operator. Since the extra data is
89  // typically small, the performance impact is minimal.
90 };
91 
92 } // namespace media
93 } // namespace edash_packager
94 
95 #endif // MEDIA_BASE_STREAM_INFO_H_
Abstract class holds stream information.
Definition: stream_info.h:25
virtual bool IsValidConfig() const =0
virtual std::string ToString() const
Definition: stream_info.cc:40