7 #ifndef PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_
8 #define PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_
10 #include <packager/crypto_params.h>
11 #include <packager/media/base/key_source.h>
12 #include <packager/media/base/media_handler.h>
18 class AesEncryptorFactory;
19 class SubsampleGenerator;
33 Status
Process(std::unique_ptr<StreamData> stream_data)
override;
37 friend class EncryptionHandlerTest;
43 Status ProcessStreamInfo(
const StreamInfo& stream_info);
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,
64 bool ExtractEac3SyncframeSizes(
const uint8_t* source,
66 std::vector<size_t>* syncframe_sizes);
69 void InjectSubsampleGeneratorForTesting(
70 std::unique_ptr<SubsampleGenerator> generator);
71 void InjectEncryptorFactoryForTesting(
72 std::unique_ptr<AesEncryptorFactory> encryptor_factory);
74 const EncryptionParams encryption_params_;
75 const FourCC protection_scheme_ = FOURCC_NULL;
77 std::string stream_label_;
79 std::shared_ptr<EncryptionConfig> encryption_config_;
80 std::unique_ptr<AesCryptor> encryptor_;
81 Codec codec_ = kUnknownCodec;
83 int64_t remaining_clear_lead_ = 0;
85 int64_t crypto_period_duration_ = 0;
87 int64_t prev_crypto_period_index_ = -1;
88 bool check_new_crypto_period_ =
false;
90 std::unique_ptr<SubsampleGenerator> subsample_generator_;
91 std::unique_ptr<AesEncryptorFactory> encryptor_factory_;
93 uint8_t crypt_byte_block_ = 0;
95 uint8_t skip_byte_block_ = 0;
All the methods that are virtual are virtual for mocking.