2014-05-08 20:53:08 +00:00
|
|
|
// Copyright 2014 Google Inc. All rights reserved.
|
|
|
|
//
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file or at
|
|
|
|
// https://developers.google.com/open-source/licenses/bsd
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/formats/mp4/encrypting_fragmenter.h"
|
2014-05-08 20:53:08 +00:00
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
#include <limits>
|
|
|
|
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/aes_encryptor.h"
|
2016-04-06 00:28:09 +00:00
|
|
|
#include "packager/media/base/aes_pattern_cryptor.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/base/buffer_reader.h"
|
|
|
|
#include "packager/media/base/key_source.h"
|
|
|
|
#include "packager/media/base/media_sample.h"
|
2016-05-25 18:03:17 +00:00
|
|
|
#include "packager/media/codecs/nalu_reader.h"
|
|
|
|
#include "packager/media/codecs/vp8_parser.h"
|
|
|
|
#include "packager/media/codecs/vp9_parser.h"
|
2014-10-01 22:10:21 +00:00
|
|
|
#include "packager/media/formats/mp4/box_definitions.h"
|
2014-05-08 20:53:08 +00:00
|
|
|
|
2016-05-20 21:19:33 +00:00
|
|
|
namespace shaka {
|
2016-02-03 22:13:57 +00:00
|
|
|
namespace media {
|
|
|
|
namespace mp4 {
|
|
|
|
|
2014-05-08 20:53:08 +00:00
|
|
|
namespace {
|
2016-01-05 00:18:34 +00:00
|
|
|
const size_t kCencBlockSize = 16u;
|
2014-05-08 20:53:08 +00:00
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
// Adds one or more subsamples to |*subsamples|. This may add more than one
|
|
|
|
// if one of the values overflows the integer in the subsample.
|
|
|
|
void AddSubsamples(uint64_t clear_bytes,
|
|
|
|
uint64_t cipher_bytes,
|
|
|
|
std::vector<SubsampleEntry>* subsamples) {
|
|
|
|
CHECK_LT(cipher_bytes, std::numeric_limits<uint32_t>::max());
|
|
|
|
const uint64_t kUInt16Max = std::numeric_limits<uint16_t>::max();
|
|
|
|
while (clear_bytes > kUInt16Max) {
|
|
|
|
subsamples->push_back(SubsampleEntry(kUInt16Max, 0));
|
|
|
|
clear_bytes -= kUInt16Max;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (clear_bytes > 0 || cipher_bytes > 0)
|
|
|
|
subsamples->push_back(SubsampleEntry(clear_bytes, cipher_bytes));
|
|
|
|
}
|
|
|
|
|
|
|
|
VideoCodec GetVideoCodec(const StreamInfo& stream_info) {
|
|
|
|
if (stream_info.stream_type() != kStreamVideo)
|
|
|
|
return kUnknownVideoCodec;
|
|
|
|
const VideoStreamInfo& video_stream_info =
|
|
|
|
static_cast<const VideoStreamInfo&>(stream_info);
|
|
|
|
return video_stream_info.codec();
|
|
|
|
}
|
2016-02-22 19:11:29 +00:00
|
|
|
|
|
|
|
uint8_t GetNaluLengthSize(const StreamInfo& stream_info) {
|
|
|
|
if (stream_info.stream_type() != kStreamVideo)
|
|
|
|
return 0;
|
|
|
|
|
|
|
|
const VideoStreamInfo& video_stream_info =
|
|
|
|
static_cast<const VideoStreamInfo&>(stream_info);
|
|
|
|
return video_stream_info.nalu_length_size();
|
|
|
|
}
|
2016-02-03 22:13:57 +00:00
|
|
|
} // namespace
|
2014-05-08 20:53:08 +00:00
|
|
|
|
|
|
|
EncryptingFragmenter::EncryptingFragmenter(
|
2016-02-03 22:13:57 +00:00
|
|
|
scoped_refptr<StreamInfo> info,
|
2014-05-08 20:53:08 +00:00
|
|
|
TrackFragment* traf,
|
|
|
|
scoped_ptr<EncryptionKey> encryption_key,
|
2016-03-17 17:03:19 +00:00
|
|
|
int64_t clear_time,
|
2016-04-06 00:28:09 +00:00
|
|
|
FourCC protection_scheme,
|
|
|
|
uint8_t crypt_byte_block,
|
|
|
|
uint8_t skip_byte_block)
|
2016-05-06 23:56:50 +00:00
|
|
|
: Fragmenter(info, traf),
|
2016-02-03 22:13:57 +00:00
|
|
|
info_(info),
|
2014-05-08 20:53:08 +00:00
|
|
|
encryption_key_(encryption_key.Pass()),
|
2016-02-22 19:11:29 +00:00
|
|
|
nalu_length_size_(GetNaluLengthSize(*info)),
|
2016-03-22 00:39:22 +00:00
|
|
|
video_codec_(GetVideoCodec(*info)),
|
2016-03-17 17:03:19 +00:00
|
|
|
clear_time_(clear_time),
|
2016-04-06 00:28:09 +00:00
|
|
|
protection_scheme_(protection_scheme),
|
|
|
|
crypt_byte_block_(crypt_byte_block),
|
|
|
|
skip_byte_block_(skip_byte_block) {
|
2014-05-08 20:53:08 +00:00
|
|
|
DCHECK(encryption_key_);
|
2016-04-06 00:28:09 +00:00
|
|
|
switch (video_codec_) {
|
|
|
|
case kCodecVP8:
|
|
|
|
vpx_parser_.reset(new VP8Parser);
|
|
|
|
break;
|
|
|
|
case kCodecVP9:
|
|
|
|
vpx_parser_.reset(new VP9Parser);
|
|
|
|
break;
|
|
|
|
case kCodecH264:
|
|
|
|
header_parser_.reset(new H264VideoSliceHeaderParser);
|
|
|
|
break;
|
|
|
|
case kCodecHVC1:
|
|
|
|
FALLTHROUGH_INTENDED;
|
|
|
|
case kCodecHEV1:
|
|
|
|
header_parser_.reset(new H265VideoSliceHeaderParser);
|
|
|
|
break;
|
|
|
|
default:
|
2016-04-21 18:17:54 +00:00
|
|
|
if (nalu_length_size_ > 0) {
|
|
|
|
LOG(WARNING) << "Unknown video codec '" << video_codec_
|
|
|
|
<< "', whole subsamples will be encrypted.";
|
|
|
|
}
|
2015-11-20 19:28:45 +00:00
|
|
|
}
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2015-11-18 19:51:15 +00:00
|
|
|
EncryptingFragmenter::~EncryptingFragmenter() {}
|
2014-05-08 20:53:08 +00:00
|
|
|
|
|
|
|
Status EncryptingFragmenter::AddSample(scoped_refptr<MediaSample> sample) {
|
|
|
|
DCHECK(sample);
|
2014-06-30 16:32:06 +00:00
|
|
|
if (!fragment_initialized()) {
|
|
|
|
Status status = InitializeFragment(sample->dts());
|
|
|
|
if (!status.ok())
|
|
|
|
return status;
|
|
|
|
}
|
2014-05-08 20:53:08 +00:00
|
|
|
if (encryptor_) {
|
|
|
|
Status status = EncryptSample(sample);
|
|
|
|
if (!status.ok())
|
|
|
|
return status;
|
|
|
|
}
|
|
|
|
return Fragmenter::AddSample(sample);
|
|
|
|
}
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
Status EncryptingFragmenter::InitializeFragment(int64_t first_sample_dts) {
|
2014-06-30 16:32:06 +00:00
|
|
|
Status status = Fragmenter::InitializeFragment(first_sample_dts);
|
2014-05-08 20:53:08 +00:00
|
|
|
if (!status.ok())
|
|
|
|
return status;
|
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
if (header_parser_ && !header_parser_->Initialize(info_->extra_data()))
|
|
|
|
return Status(error::MUXER_FAILURE, "Fail to read SPS and PPS data.");
|
|
|
|
|
2014-05-08 21:50:38 +00:00
|
|
|
traf()->auxiliary_size.sample_info_sizes.clear();
|
|
|
|
traf()->auxiliary_offset.offsets.clear();
|
2015-02-06 20:31:46 +00:00
|
|
|
if (IsSubsampleEncryptionRequired()) {
|
|
|
|
traf()->sample_encryption.flags |=
|
|
|
|
SampleEncryption::kUseSubsampleEncryption;
|
|
|
|
}
|
|
|
|
traf()->sample_encryption.sample_encryption_entries.clear();
|
2014-05-08 20:53:08 +00:00
|
|
|
|
2014-05-08 21:50:38 +00:00
|
|
|
const bool enable_encryption = clear_time_ <= 0;
|
|
|
|
if (!enable_encryption) {
|
|
|
|
// This fragment should be in clear text.
|
|
|
|
// At most two sample description entries, an encrypted entry and a clear
|
|
|
|
// entry, are generated. The 1-based clear entry index is always 2.
|
2014-09-30 21:52:21 +00:00
|
|
|
const uint32_t kClearSampleDescriptionIndex = 2;
|
2014-05-08 20:53:08 +00:00
|
|
|
|
2014-05-08 21:50:38 +00:00
|
|
|
traf()->header.flags |=
|
|
|
|
TrackFragmentHeader::kSampleDescriptionIndexPresentMask;
|
|
|
|
traf()->header.sample_description_index = kClearSampleDescriptionIndex;
|
|
|
|
}
|
|
|
|
return PrepareFragmentForEncryption(enable_encryption);
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EncryptingFragmenter::FinalizeFragment() {
|
|
|
|
if (encryptor_) {
|
|
|
|
DCHECK_LE(clear_time_, 0);
|
|
|
|
FinalizeFragmentForEncryption();
|
|
|
|
} else {
|
|
|
|
DCHECK_GT(clear_time_, 0);
|
|
|
|
clear_time_ -= fragment_duration();
|
|
|
|
}
|
|
|
|
Fragmenter::FinalizeFragment();
|
|
|
|
}
|
|
|
|
|
2014-05-08 21:50:38 +00:00
|
|
|
Status EncryptingFragmenter::PrepareFragmentForEncryption(
|
|
|
|
bool enable_encryption) {
|
|
|
|
return (!enable_encryption || encryptor_) ? Status::OK : CreateEncryptor();
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EncryptingFragmenter::FinalizeFragmentForEncryption() {
|
|
|
|
// The offset will be adjusted in Segmenter after knowing moof size.
|
|
|
|
traf()->auxiliary_offset.offsets.push_back(0);
|
|
|
|
|
2016-04-06 00:28:09 +00:00
|
|
|
// For 'cbcs' scheme, Constant IVs SHALL be used.
|
|
|
|
const size_t per_sample_iv_size =
|
|
|
|
(protection_scheme_ == FOURCC_cbcs) ? 0 : encryptor_->iv().size();
|
|
|
|
traf()->sample_encryption.iv_size = per_sample_iv_size;
|
|
|
|
|
2014-05-08 20:53:08 +00:00
|
|
|
// Optimize saiz box.
|
|
|
|
SampleAuxiliaryInformationSize& saiz = traf()->auxiliary_size;
|
|
|
|
saiz.sample_count = traf()->runs[0].sample_sizes.size();
|
|
|
|
if (!saiz.sample_info_sizes.empty()) {
|
|
|
|
if (!OptimizeSampleEntries(&saiz.sample_info_sizes,
|
|
|
|
&saiz.default_sample_info_size)) {
|
|
|
|
saiz.default_sample_info_size = 0;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
// |sample_info_sizes| table is filled in only for subsample encryption,
|
|
|
|
// otherwise |sample_info_size| is just the IV size.
|
|
|
|
DCHECK(!IsSubsampleEncryptionRequired());
|
2016-04-06 00:28:09 +00:00
|
|
|
saiz.default_sample_info_size = per_sample_iv_size;
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
2016-04-06 00:28:09 +00:00
|
|
|
// It should only happen with full sample encryption + constant iv, which is
|
|
|
|
// not a legal combination.
|
|
|
|
CHECK(!saiz.sample_info_sizes.empty() || saiz.default_sample_info_size != 0);
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status EncryptingFragmenter::CreateEncryptor() {
|
|
|
|
DCHECK(encryption_key_);
|
2016-04-08 18:41:17 +00:00
|
|
|
scoped_ptr<AesCryptor> encryptor;
|
|
|
|
switch (protection_scheme_) {
|
|
|
|
case FOURCC_cenc:
|
|
|
|
encryptor.reset(new AesCtrEncryptor);
|
|
|
|
break;
|
|
|
|
case FOURCC_cbc1:
|
2016-04-13 17:52:41 +00:00
|
|
|
encryptor.reset(new AesCbcEncryptor(kNoPadding));
|
2016-04-08 18:41:17 +00:00
|
|
|
break;
|
2016-04-06 00:28:09 +00:00
|
|
|
case FOURCC_cens:
|
2016-04-13 17:52:41 +00:00
|
|
|
encryptor.reset(new AesPatternCryptor(
|
2016-04-27 07:51:51 +00:00
|
|
|
crypt_byte_block(), skip_byte_block(),
|
|
|
|
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
|
|
|
|
AesCryptor::kDontUseConstantIv,
|
|
|
|
scoped_ptr<AesCryptor>(new AesCtrEncryptor())));
|
2016-04-06 00:28:09 +00:00
|
|
|
break;
|
|
|
|
case FOURCC_cbcs:
|
2016-04-13 17:52:41 +00:00
|
|
|
encryptor.reset(new AesPatternCryptor(
|
2016-04-27 07:51:51 +00:00
|
|
|
crypt_byte_block(), skip_byte_block(),
|
|
|
|
AesPatternCryptor::kEncryptIfCryptByteBlockRemaining,
|
|
|
|
AesCryptor::kUseConstantIv,
|
2016-04-13 17:52:41 +00:00
|
|
|
scoped_ptr<AesCryptor>(new AesCbcEncryptor(kNoPadding))));
|
2016-04-06 00:28:09 +00:00
|
|
|
break;
|
2016-04-08 18:41:17 +00:00
|
|
|
default:
|
|
|
|
return Status(error::MUXER_FAILURE, "Unsupported protection scheme.");
|
2016-03-17 17:03:19 +00:00
|
|
|
}
|
2016-04-08 18:41:17 +00:00
|
|
|
|
|
|
|
DCHECK(!encryption_key_->iv.empty());
|
|
|
|
const bool initialized =
|
|
|
|
encryptor->InitializeWithIv(encryption_key_->key, encryption_key_->iv);
|
2014-05-08 20:53:08 +00:00
|
|
|
if (!initialized)
|
|
|
|
return Status(error::MUXER_FAILURE, "Failed to create the encryptor.");
|
|
|
|
encryptor_ = encryptor.Pass();
|
|
|
|
return Status::OK;
|
|
|
|
}
|
|
|
|
|
2014-09-30 21:52:21 +00:00
|
|
|
void EncryptingFragmenter::EncryptBytes(uint8_t* data, uint32_t size) {
|
2014-05-08 20:53:08 +00:00
|
|
|
DCHECK(encryptor_);
|
2016-04-06 00:19:16 +00:00
|
|
|
CHECK(encryptor_->Crypt(data, size, data));
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
Status EncryptingFragmenter::EncryptSample(scoped_refptr<MediaSample> sample) {
|
|
|
|
DCHECK(encryptor_);
|
|
|
|
|
2015-02-06 20:31:46 +00:00
|
|
|
SampleEncryptionEntry sample_encryption_entry;
|
2016-04-06 00:28:09 +00:00
|
|
|
// For 'cbcs' scheme, Constant IVs SHALL be used.
|
|
|
|
if (protection_scheme_ != FOURCC_cbcs)
|
|
|
|
sample_encryption_entry.initialization_vector = encryptor_->iv();
|
2014-09-30 21:52:21 +00:00
|
|
|
uint8_t* data = sample->writable_data();
|
2015-11-18 19:51:15 +00:00
|
|
|
if (IsSubsampleEncryptionRequired()) {
|
2015-11-20 19:28:45 +00:00
|
|
|
if (vpx_parser_) {
|
2015-11-18 19:51:15 +00:00
|
|
|
std::vector<VPxFrameInfo> vpx_frames;
|
2015-11-20 19:28:45 +00:00
|
|
|
if (!vpx_parser_->Parse(sample->data(), sample->data_size(),
|
2015-11-18 19:51:15 +00:00
|
|
|
&vpx_frames)) {
|
2015-11-20 19:28:45 +00:00
|
|
|
return Status(error::MUXER_FAILURE, "Failed to parse vpx frame.");
|
2015-11-18 19:51:15 +00:00
|
|
|
}
|
2016-01-05 00:18:34 +00:00
|
|
|
|
|
|
|
const bool is_superframe = vpx_frames.size() > 1;
|
2015-11-18 19:51:15 +00:00
|
|
|
for (const VPxFrameInfo& frame : vpx_frames) {
|
|
|
|
SubsampleEntry subsample;
|
|
|
|
subsample.clear_bytes = frame.uncompressed_header_size;
|
|
|
|
subsample.cipher_bytes =
|
|
|
|
frame.frame_size - frame.uncompressed_header_size;
|
2016-01-05 00:18:34 +00:00
|
|
|
|
|
|
|
// "VP Codec ISO Media File Format Binding" document requires that the
|
|
|
|
// encrypted bytes of each frame within the superframe must be block
|
|
|
|
// aligned so that the counter state can be computed for each frame
|
|
|
|
// within the superframe.
|
2016-04-21 23:28:21 +00:00
|
|
|
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
|
|
|
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
|
|
|
// avoid partial blocks in Subsamples.
|
|
|
|
if (is_superframe || protection_scheme_ == FOURCC_cbc1 ||
|
|
|
|
protection_scheme_ == FOURCC_cens) {
|
2016-03-25 18:02:43 +00:00
|
|
|
const uint16_t misalign_bytes =
|
|
|
|
subsample.cipher_bytes % kCencBlockSize;
|
2016-01-05 00:18:34 +00:00
|
|
|
subsample.clear_bytes += misalign_bytes;
|
|
|
|
subsample.cipher_bytes -= misalign_bytes;
|
|
|
|
}
|
|
|
|
|
2015-02-06 20:31:46 +00:00
|
|
|
sample_encryption_entry.subsamples.push_back(subsample);
|
2015-11-18 19:51:15 +00:00
|
|
|
if (subsample.cipher_bytes > 0)
|
|
|
|
EncryptBytes(data + subsample.clear_bytes, subsample.cipher_bytes);
|
|
|
|
data += frame.frame_size;
|
|
|
|
}
|
|
|
|
} else {
|
2016-04-21 20:35:49 +00:00
|
|
|
const Nalu::CodecType nalu_type =
|
2016-03-22 00:39:22 +00:00
|
|
|
(video_codec_ == kCodecHVC1 || video_codec_ == kCodecHEV1)
|
2016-04-21 20:35:49 +00:00
|
|
|
? Nalu::kH265
|
|
|
|
: Nalu::kH264;
|
2016-02-26 22:34:14 +00:00
|
|
|
NaluReader reader(nalu_type, nalu_length_size_, data,
|
|
|
|
sample->data_size());
|
2016-02-03 22:13:57 +00:00
|
|
|
|
|
|
|
// Store the current length of clear data. This is used to squash
|
|
|
|
// multiple unencrypted NAL units into fewer subsample entries.
|
|
|
|
uint64_t accumulated_clear_bytes = 0;
|
2015-11-18 19:51:15 +00:00
|
|
|
|
2016-02-05 19:08:07 +00:00
|
|
|
Nalu nalu;
|
|
|
|
NaluReader::Result result;
|
|
|
|
while ((result = reader.Advance(&nalu)) == NaluReader::kOk) {
|
2016-02-03 22:13:57 +00:00
|
|
|
if (nalu.is_video_slice()) {
|
|
|
|
// For video-slice NAL units, encrypt the video slice. This skips
|
|
|
|
// the frame header. If this is an unrecognized codec (e.g. H.265),
|
|
|
|
// the whole NAL unit will be encrypted.
|
|
|
|
const int64_t video_slice_header_size =
|
|
|
|
header_parser_ ? header_parser_->GetHeaderSize(nalu) : 0;
|
|
|
|
if (video_slice_header_size < 0)
|
|
|
|
return Status(error::MUXER_FAILURE, "Failed to read slice header.");
|
|
|
|
|
2016-03-25 18:02:43 +00:00
|
|
|
uint64_t current_clear_bytes =
|
|
|
|
nalu.header_size() + video_slice_header_size;
|
|
|
|
uint64_t cipher_bytes = nalu.payload_size() - video_slice_header_size;
|
|
|
|
|
2016-04-21 23:28:21 +00:00
|
|
|
// ISO/IEC 23001-7:2016 10.2 'cbc1' 10.3 'cens'
|
|
|
|
// The BytesOfProtectedData size SHALL be a multiple of 16 bytes to
|
|
|
|
// avoid partial blocks in Subsamples.
|
|
|
|
if (protection_scheme_ == FOURCC_cbc1 ||
|
|
|
|
protection_scheme_ == FOURCC_cens) {
|
2016-03-25 18:02:43 +00:00
|
|
|
const uint16_t misalign_bytes = cipher_bytes % kCencBlockSize;
|
|
|
|
current_clear_bytes += misalign_bytes;
|
|
|
|
cipher_bytes -= misalign_bytes;
|
|
|
|
}
|
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
const uint8_t* nalu_data = nalu.data() + current_clear_bytes;
|
|
|
|
EncryptBytes(const_cast<uint8_t*>(nalu_data), cipher_bytes);
|
2015-02-06 20:31:46 +00:00
|
|
|
|
2016-02-22 19:11:29 +00:00
|
|
|
AddSubsamples(
|
|
|
|
accumulated_clear_bytes + nalu_length_size_ + current_clear_bytes,
|
|
|
|
cipher_bytes, &sample_encryption_entry.subsamples);
|
2016-02-03 22:13:57 +00:00
|
|
|
accumulated_clear_bytes = 0;
|
|
|
|
} else {
|
|
|
|
// For non-video-slice NAL units, don't encrypt.
|
2016-03-15 00:42:40 +00:00
|
|
|
accumulated_clear_bytes +=
|
|
|
|
nalu_length_size_ + nalu.header_size() + nalu.payload_size();
|
2016-02-03 22:13:57 +00:00
|
|
|
}
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
2016-02-05 19:08:07 +00:00
|
|
|
if (result != NaluReader::kEOStream)
|
|
|
|
return Status(error::MUXER_FAILURE, "Failed to parse NAL units.");
|
2016-02-03 22:13:57 +00:00
|
|
|
AddSubsamples(accumulated_clear_bytes, 0,
|
|
|
|
&sample_encryption_entry.subsamples);
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// The length of per-sample auxiliary datum, defined in CENC ch. 7.
|
2015-02-06 20:31:46 +00:00
|
|
|
traf()->auxiliary_size.sample_info_sizes.push_back(
|
|
|
|
sample_encryption_entry.ComputeSize());
|
2015-11-18 19:51:15 +00:00
|
|
|
} else {
|
2016-04-13 23:43:55 +00:00
|
|
|
EncryptBytes(data, sample->data_size());
|
2014-05-08 20:53:08 +00:00
|
|
|
}
|
|
|
|
|
2015-02-06 20:31:46 +00:00
|
|
|
traf()->sample_encryption.sample_encryption_entries.push_back(
|
|
|
|
sample_encryption_entry);
|
2014-05-08 20:53:08 +00:00
|
|
|
encryptor_->UpdateIv();
|
|
|
|
return Status::OK;
|
|
|
|
}
|
|
|
|
|
2016-02-03 22:13:57 +00:00
|
|
|
bool EncryptingFragmenter::IsSubsampleEncryptionRequired() {
|
2016-02-22 19:11:29 +00:00
|
|
|
return vpx_parser_ || nalu_length_size_ != 0;
|
2016-02-03 22:13:57 +00:00
|
|
|
}
|
|
|
|
|
2014-05-08 20:53:08 +00:00
|
|
|
} // namespace mp4
|
|
|
|
} // namespace media
|
2016-05-20 21:19:33 +00:00
|
|
|
} // namespace shaka
|