7 #ifndef MEDIA_BASE_MEDIA_SAMPLE_H_
8 #define MEDIA_BASE_MEDIA_SAMPLE_H_
14 #include "packager/base/logging.h"
15 #include "packager/base/memory/ref_counted.h"
16 #include "packager/base/memory/scoped_ptr.h"
18 namespace edash_packager {
22 class MediaSample :
public base::RefCountedThreadSafe<MediaSample> {
29 static scoped_refptr<MediaSample>
CopyFrom(
const uint8_t* data,
42 static scoped_refptr<MediaSample>
CopyFrom(
const uint8_t* data,
44 const uint8_t* side_data,
45 size_t side_data_size,
54 static scoped_refptr<MediaSample>
FromMetadata(
const uint8_t* metadata,
55 size_t metadata_size);
66 DCHECK(!end_of_stream());
70 void set_dts(int64_t dts) { dts_ = dts; }
73 DCHECK(!end_of_stream());
77 void set_pts(int64_t pts) { pts_ = pts; }
79 int64_t duration()
const {
80 DCHECK(!end_of_stream());
84 void set_duration(int64_t duration) {
85 DCHECK(!end_of_stream());
89 bool is_key_frame()
const {
90 DCHECK(!end_of_stream());
94 bool is_encrypted()
const {
95 DCHECK(!end_of_stream());
98 const uint8_t* data()
const {
99 DCHECK(!end_of_stream());
103 uint8_t* writable_data() {
104 DCHECK(!end_of_stream());
108 size_t data_size()
const {
109 DCHECK(!end_of_stream());
113 const uint8_t* side_data()
const {
114 return &side_data_[0];
117 size_t side_data_size()
const {
118 return side_data_.size();
121 void set_data(
const uint8_t* data,
const size_t data_size) {
122 data_.assign(data, data + data_size);
125 void set_is_key_frame(
bool value) {
126 is_key_frame_ = value;
129 void set_is_encrypted(
bool value) {
130 is_encrypted_ = value;
134 bool end_of_stream()
const {
return data_.size() == 0; }
136 const std::string& config_id()
const {
return config_id_; }
137 void set_config_id(
const std::string& config_id) {
138 config_id_ = config_id;
145 friend class base::RefCountedThreadSafe<MediaSample>;
150 MediaSample(
const uint8_t* data,
152 const uint8_t* side_data,
153 size_t side_data_size,
156 virtual ~MediaSample();
168 std::vector<uint8_t> data_;
172 std::vector<uint8_t> side_data_;
176 std::string config_id_;
178 DISALLOW_COPY_AND_ASSIGN(MediaSample);
181 typedef std::deque<scoped_refptr<MediaSample> > BufferQueue;
186 #endif // MEDIA_BASE_MEDIA_SAMPLE_H_