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/packager.h"
18 class VideoSliceHeaderParser;
36 std::function<std::string(
37 const EncryptionParams::EncryptedStreamAttributes& stream_attributes)>
52 Status Process(std::unique_ptr<StreamData> stream_data)
override;
56 friend class EncryptionHandlerTest;
66 Status SetupProtectionPattern(StreamType stream_type);
68 bool EncryptVpxFrame(
const std::vector<VPxFrameInfo>& vpx_frames,
72 void EncryptBytes(uint8_t* data,
size_t size);
75 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
76 void InjectVideoSliceHeaderParserForTesting(
77 std::unique_ptr<VideoSliceHeaderParser> header_parser);
81 std::string stream_label_;
83 std::shared_ptr<EncryptionConfig> encryption_config_;
84 std::unique_ptr<AesCryptor> encryptor_;
85 Codec codec_ = kUnknownCodec;
88 uint8_t nalu_length_size_ = 0;
90 size_t leading_clear_bytes_size_ = 0;
92 size_t min_protected_data_size_ = 0;
94 int64_t remaining_clear_lead_ = 0;
96 uint64_t crypto_period_duration_ = 0;
98 int64_t prev_crypto_period_index_ = -1;
99 bool check_new_crypto_period_ =
false;
102 uint8_t crypt_byte_block_ = 0;
104 uint8_t skip_byte_block_ = 0;
107 std::unique_ptr<VPxParser> vpx_parser_;
109 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
115 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_