7 #ifndef PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_
8 #define PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_
10 #include "packager/media/base/key_source.h"
11 #include "packager/media/base/media_handler.h"
12 #include "packager/media/public/crypto_params.h"
18 class AesEncryptorFactory;
19 class SubsampleGenerator;
33 Status Process(std::unique_ptr<StreamData> stream_data)
override;
37 friend class EncryptionHandlerTest;
45 Status ProcessMediaSample(std::shared_ptr<const MediaSample> clear_sample);
47 void SetupProtectionPattern(StreamType stream_type);
51 bool SampleAesEncryptEac3Frame(
const uint8_t* source,
56 void EncryptBytes(
const uint8_t* source,
size_t source_size, uint8_t* dest);
61 bool ExtractEac3SyncframeSizes(
const uint8_t* source,
63 std::vector<size_t>* syncframe_sizes);
66 void InjectSubsampleGeneratorForTesting(
67 std::unique_ptr<SubsampleGenerator> generator);
68 void InjectEncryptorFactoryForTesting(
69 std::unique_ptr<AesEncryptorFactory> encryptor_factory);
72 const FourCC protection_scheme_ = FOURCC_NULL;
74 std::string stream_label_;
76 std::shared_ptr<EncryptionConfig> encryption_config_;
77 std::unique_ptr<AesCryptor> encryptor_;
78 Codec codec_ = kUnknownCodec;
80 int64_t remaining_clear_lead_ = 0;
82 uint64_t crypto_period_duration_ = 0;
84 int64_t prev_crypto_period_index_ = -1;
85 bool check_new_crypto_period_ =
false;
87 std::unique_ptr<SubsampleGenerator> subsample_generator_;
88 std::unique_ptr<AesEncryptorFactory> encryptor_factory_;
90 uint8_t crypt_byte_block_ = 0;
92 uint8_t skip_byte_block_ = 0;
98 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_