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 resize_data(
const size_t data_size) {
126 data_.resize(data_size);
129 void set_is_key_frame(
bool value) {
130 is_key_frame_ = value;
133 void set_is_encrypted(
bool value) {
134 is_encrypted_ = value;
138 bool end_of_stream()
const {
return data_.size() == 0; }
140 const std::string& config_id()
const {
return config_id_; }
141 void set_config_id(
const std::string& config_id) {
142 config_id_ = config_id;
149 friend class base::RefCountedThreadSafe<MediaSample>;
154 MediaSample(
const uint8_t* data,
156 const uint8_t* side_data,
157 size_t side_data_size,
160 virtual ~MediaSample();
172 std::vector<uint8_t> data_;
176 std::vector<uint8_t> side_data_;
180 std::string config_id_;
182 DISALLOW_COPY_AND_ASSIGN(MediaSample);
185 typedef std::deque<scoped_refptr<MediaSample> > BufferQueue;
190 #endif // MEDIA_BASE_MEDIA_SAMPLE_H_