7 #ifndef PACKAGER_MEDIA_BASE_MEDIA_SAMPLE_H_
8 #define PACKAGER_MEDIA_BASE_MEDIA_SAMPLE_H_
15 #include <absl/log/check.h>
16 #include <absl/log/log.h>
18 #include <packager/macros/classes.h>
19 #include <packager/media/base/decrypt_config.h>
32 static std::shared_ptr<MediaSample>
CopyFrom(
const uint8_t* data,
45 static std::shared_ptr<MediaSample>
CopyFrom(
const uint8_t* data,
47 const uint8_t* side_data,
48 size_t side_data_size,
57 static std::shared_ptr<MediaSample>
FromMetadata(
const uint8_t* metadata,
58 size_t metadata_size);
71 std::shared_ptr<MediaSample>
Clone()
const;
76 void TransferData(std::shared_ptr<uint8_t> data,
size_t data_size);
82 void SetData(
const uint8_t* data,
size_t data_size);
88 DCHECK(!end_of_stream());
92 void set_dts(int64_t dts) { dts_ = dts; }
95 DCHECK(!end_of_stream());
99 void set_pts(int64_t pts) { pts_ = pts; }
101 int64_t duration()
const {
102 DCHECK(!end_of_stream());
106 void set_duration(int64_t duration) {
107 DCHECK(!end_of_stream());
108 duration_ = duration;
111 bool is_key_frame()
const {
112 DCHECK(!end_of_stream());
113 return is_key_frame_;
116 bool is_encrypted()
const {
117 DCHECK(!end_of_stream());
118 return is_encrypted_;
120 const uint8_t* data()
const {
121 DCHECK(!end_of_stream());
125 size_t data_size()
const {
126 DCHECK(!end_of_stream());
130 const uint8_t* side_data()
const {
return side_data_.get(); }
132 size_t side_data_size()
const {
return side_data_size_; }
134 const DecryptConfig* decrypt_config()
const {
return decrypt_config_.get(); }
136 void set_is_key_frame(
bool value) {
137 is_key_frame_ = value;
140 void set_is_encrypted(
bool value) {
141 is_encrypted_ = value;
144 void set_decrypt_config(std::unique_ptr<DecryptConfig> decrypt_config) {
145 decrypt_config_ = std::move(decrypt_config);
149 bool end_of_stream()
const {
return data_size_ == 0; }
151 const std::string& config_id()
const {
return config_id_; }
152 void set_config_id(
const std::string& config_id) {
153 config_id_ = config_id;
162 const uint8_t* side_data,
163 size_t side_data_size,
172 int64_t duration_ = 0;
173 bool is_key_frame_ =
false;
175 bool is_encrypted_ =
false;
178 std::shared_ptr<const uint8_t> data_;
179 size_t data_size_ = 0;
183 std::shared_ptr<const uint8_t> side_data_;
184 size_t side_data_size_ = 0;
188 std::string config_id_;
191 std::unique_ptr<DecryptConfig> decrypt_config_;
196 typedef std::deque<std::shared_ptr<MediaSample>> BufferQueue;
All the methods that are virtual are virtual for mocking.