7 #ifndef PACKAGER_MEDIA_BASE_MEDIA_SAMPLE_H_
8 #define PACKAGER_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);
68 std::shared_ptr<MediaSample>
Clone()
const;
73 void TransferData(std::shared_ptr<uint8_t> data,
size_t data_size);
79 void SetData(
const uint8_t* data,
size_t data_size);
85 DCHECK(!end_of_stream());
89 void set_dts(int64_t dts) { dts_ = dts; }
92 DCHECK(!end_of_stream());
96 void set_pts(int64_t pts) { pts_ = pts; }
98 int64_t duration()
const {
99 DCHECK(!end_of_stream());
103 void set_duration(int64_t duration) {
104 DCHECK(!end_of_stream());
105 duration_ = duration;
108 bool is_key_frame()
const {
109 DCHECK(!end_of_stream());
110 return is_key_frame_;
113 bool is_encrypted()
const {
114 DCHECK(!end_of_stream());
115 return is_encrypted_;
117 const uint8_t* data()
const {
118 DCHECK(!end_of_stream());
122 size_t data_size()
const {
123 DCHECK(!end_of_stream());
127 const uint8_t* side_data()
const {
return side_data_.get(); }
129 size_t side_data_size()
const {
return side_data_size_; }
131 const DecryptConfig* decrypt_config()
const {
return decrypt_config_.get(); }
133 void set_is_key_frame(
bool value) {
134 is_key_frame_ = value;
137 void set_is_encrypted(
bool value) {
138 is_encrypted_ = value;
141 void set_decrypt_config(std::unique_ptr<DecryptConfig> decrypt_config) {
142 decrypt_config_ = std::move(decrypt_config);
146 bool end_of_stream()
const {
return data_size_ == 0; }
148 const std::string& config_id()
const {
return config_id_; }
149 void set_config_id(
const std::string& config_id) {
150 config_id_ = config_id;
159 const uint8_t* side_data,
160 size_t side_data_size,
169 int64_t duration_ = 0;
170 bool is_key_frame_ =
false;
172 bool is_encrypted_ =
false;
175 std::shared_ptr<const uint8_t> data_;
176 size_t data_size_ = 0;
180 std::shared_ptr<const uint8_t> side_data_;
181 size_t side_data_size_ = 0;
185 std::string config_id_;
188 std::unique_ptr<DecryptConfig> decrypt_config_;
193 typedef std::deque<std::shared_ptr<MediaSample>> BufferQueue;
198 #endif // PACKAGER_MEDIA_BASE_MEDIA_SAMPLE_H_