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 VideoSliceHeaderParser;
34 Status Process(std::unique_ptr<StreamData> stream_data)
override;
38 friend class EncryptionHandlerTest;
46 Status ProcessMediaSample(std::shared_ptr<const MediaSample> clear_sample);
48 Status SetupProtectionPattern(StreamType stream_type);
50 bool EncryptVpxFrame(
const std::vector<VPxFrameInfo>& vpx_frames,
54 bool EncryptNalFrame(uint8_t* data,
57 void EncryptBytes(uint8_t* data,
61 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
62 void InjectVideoSliceHeaderParserForTesting(
63 std::unique_ptr<VideoSliceHeaderParser> header_parser);
66 const FourCC protection_scheme_ = FOURCC_NULL;
68 std::string stream_label_;
70 std::shared_ptr<EncryptionConfig> encryption_config_;
71 std::unique_ptr<AesCryptor> encryptor_;
72 Codec codec_ = kUnknownCodec;
75 uint8_t nalu_length_size_ = 0;
77 size_t leading_clear_bytes_size_ = 0;
79 size_t min_protected_data_size_ = 0;
81 int64_t remaining_clear_lead_ = 0;
83 uint64_t crypto_period_duration_ = 0;
85 int64_t prev_crypto_period_index_ = -1;
86 bool check_new_crypto_period_ =
false;
89 uint8_t crypt_byte_block_ = 0;
91 uint8_t skip_byte_block_ = 0;
94 std::unique_ptr<VPxParser> vpx_parser_;
96 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
102 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_