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,
43 static scoped_refptr<MediaSample>
CopyFrom(
const uint8_t* data,
45 const uint8_t* side_data,
46 size_t side_data_size,
58 DCHECK(!end_of_stream());
62 void set_dts(int64_t dts) { dts_ = dts; }
65 DCHECK(!end_of_stream());
69 void set_pts(int64_t pts) { pts_ = pts; }
71 int64_t duration()
const {
72 DCHECK(!end_of_stream());
76 void set_duration(int64_t duration) {
77 DCHECK(!end_of_stream());
81 bool is_key_frame()
const {
82 DCHECK(!end_of_stream());
86 bool is_encrypted()
const {
87 DCHECK(!end_of_stream());
90 const uint8_t* data()
const {
91 DCHECK(!end_of_stream());
95 uint8_t* writable_data() {
96 DCHECK(!end_of_stream());
100 size_t data_size()
const {
101 DCHECK(!end_of_stream());
105 const uint8_t* side_data()
const {
106 DCHECK(!end_of_stream());
107 return &side_data_[0];
110 size_t side_data_size()
const {
111 DCHECK(!end_of_stream());
112 return side_data_.size();
115 void set_data(
const uint8_t* data,
const size_t data_size) {
116 data_.assign(data, data + data_size);
119 void set_is_key_frame(
bool value) {
120 is_key_frame_ = value;
123 void set_is_encrypted(
bool value) {
124 is_encrypted_ = value;
128 bool end_of_stream()
const {
return data_.size() == 0; }
134 friend class base::RefCountedThreadSafe<MediaSample>;
139 MediaSample(
const uint8_t* data,
141 const uint8_t* side_data,
142 size_t side_data_size,
145 virtual ~MediaSample();
157 std::vector<uint8_t> data_;
161 std::vector<uint8_t> side_data_;
163 DISALLOW_COPY_AND_ASSIGN(MediaSample);
166 typedef std::deque<scoped_refptr<MediaSample> > BufferQueue;
171 #endif // MEDIA_BASE_MEDIA_SAMPLE_H_