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);
52 bool EncryptVpxFrame(
const std::vector<VPxFrameInfo>& vpx_frames,
53 const uint8_t* source,
59 bool EncryptNalFrame(
const uint8_t* source,
65 void EncryptBytes(
const uint8_t* source,
size_t source_size, uint8_t* dest);
68 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
69 void InjectVideoSliceHeaderParserForTesting(
70 std::unique_ptr<VideoSliceHeaderParser> header_parser);
73 const FourCC protection_scheme_ = FOURCC_NULL;
75 std::string stream_label_;
77 std::shared_ptr<EncryptionConfig> encryption_config_;
78 std::unique_ptr<AesCryptor> encryptor_;
79 Codec codec_ = kUnknownCodec;
82 uint8_t nalu_length_size_ = 0;
84 size_t leading_clear_bytes_size_ = 0;
86 size_t min_protected_data_size_ = 0;
88 int64_t remaining_clear_lead_ = 0;
90 uint64_t crypto_period_duration_ = 0;
92 int64_t prev_crypto_period_index_ = -1;
93 bool check_new_crypto_period_ =
false;
96 uint8_t crypt_byte_block_ = 0;
98 uint8_t skip_byte_block_ = 0;
101 std::unique_ptr<VPxParser> vpx_parser_;
103 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
109 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_