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