7 #include "packager/media/base/media_sample.h"
11 #include "packager/base/logging.h"
12 #include "packager/base/strings/stringprintf.h"
17 MediaSample::MediaSample(
const uint8_t* data,
19 const uint8_t* side_data,
20 size_t side_data_size,
25 is_key_frame_(is_key_frame),
26 is_encrypted_(false) {
31 data_.assign(data, data + size);
33 side_data_.assign(side_data, side_data + side_data_size);
36 MediaSample::MediaSample() : dts_(0),
40 is_encrypted_(false) {}
42 MediaSample::~MediaSample() {}
50 return std::make_shared<MediaSample>(data, data_size,
nullptr, 0u,
57 const uint8_t* side_data,
58 size_t side_data_size,
62 return std::make_shared<MediaSample>(data, data_size, side_data,
63 side_data_size, is_key_frame);
69 std::shared_ptr<MediaSample> new_media_sample =
CopyFrom(
70 media_sample.data(), media_sample.data_size(), media_sample.side_data(),
71 media_sample.side_data_size(), media_sample.is_key_frame());
73 new_media_sample->set_dts(media_sample.dts());
74 new_media_sample->set_pts(media_sample.pts());
75 new_media_sample->set_is_encrypted(media_sample.is_encrypted());
76 new_media_sample->set_config_id(media_sample.config_id());
77 new_media_sample->set_duration(media_sample.duration());
79 if (media_sample.decrypt_config()) {
80 std::unique_ptr<DecryptConfig> decrypt_config(
82 media_sample.decrypt_config()->iv(),
83 media_sample.decrypt_config()->subsamples(),
84 media_sample.decrypt_config()->protection_scheme(),
85 media_sample.decrypt_config()->crypt_byte_block(),
86 media_sample.decrypt_config()->skip_byte_block()));
87 new_media_sample->set_decrypt_config(std::move(decrypt_config));
89 return new_media_sample;
94 size_t metadata_size) {
95 return std::make_shared<MediaSample>(
nullptr, 0, metadata, metadata_size,
101 return std::make_shared<MediaSample>();
106 return std::make_shared<MediaSample>(
nullptr, 0,
nullptr, 0,
false);
111 return "End of stream sample\n";
112 return base::StringPrintf(
113 "dts: %" PRId64
"\n pts: %" PRId64
"\n duration: %" PRId64
"\n "
114 "is_key_frame: %s\n size: %zu\n side_data_size: %zu\n",
118 is_key_frame_ ?
"true" :
"false",