7 #ifndef MEDIA_BASE_MEDIA_SAMPLE_H_
8 #define MEDIA_BASE_MEDIA_SAMPLE_H_
15 #include "packager/base/logging.h"
16 #include "packager/media/base/decrypt_config.h"
29 static std::shared_ptr<MediaSample>
CopyFrom(
const uint8_t* data,
42 static std::shared_ptr<MediaSample>
CopyFrom(
const uint8_t* data,
44 const uint8_t* side_data,
45 size_t side_data_size,
54 static std::shared_ptr<MediaSample>
FromMetadata(
const uint8_t* metadata,
55 size_t metadata_size);
70 const uint8_t* side_data,
71 size_t side_data_size,
77 DCHECK(!end_of_stream());
81 void set_dts(int64_t dts) { dts_ = dts; }
84 DCHECK(!end_of_stream());
88 void set_pts(int64_t pts) { pts_ = pts; }
90 int64_t duration()
const {
91 DCHECK(!end_of_stream());
95 void set_duration(int64_t duration) {
96 DCHECK(!end_of_stream());
100 bool is_key_frame()
const {
101 DCHECK(!end_of_stream());
102 return is_key_frame_;
105 bool is_encrypted()
const {
106 DCHECK(!end_of_stream());
107 return is_encrypted_;
109 const uint8_t* data()
const {
110 DCHECK(!end_of_stream());
114 uint8_t* writable_data() {
115 DCHECK(!end_of_stream());
119 size_t data_size()
const {
120 DCHECK(!end_of_stream());
124 const uint8_t* side_data()
const {
125 return &side_data_[0];
128 size_t side_data_size()
const {
129 return side_data_.size();
133 return decrypt_config_.get();
136 void set_data(
const uint8_t* data,
const size_t data_size) {
137 data_.assign(data, data + data_size);
140 void resize_data(
const size_t data_size) {
141 data_.resize(data_size);
144 void set_is_key_frame(
bool value) {
145 is_key_frame_ = value;
148 void set_is_encrypted(
bool value) {
149 is_encrypted_ = value;
152 void set_decrypt_config(std::unique_ptr<DecryptConfig> decrypt_config) {
153 decrypt_config_ = std::move(decrypt_config);
157 bool end_of_stream()
const {
return data_.size() == 0; }
159 const std::string& config_id()
const {
return config_id_; }
160 void set_config_id(
const std::string& config_id) {
161 config_id_ = config_id;
178 std::vector<uint8_t> data_;
182 std::vector<uint8_t> side_data_;
186 std::string config_id_;
189 std::unique_ptr<DecryptConfig> decrypt_config_;
194 typedef std::deque<std::shared_ptr<MediaSample>> BufferQueue;
199 #endif // MEDIA_BASE_MEDIA_SAMPLE_H_