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;
44 Status ProcessStreamInfo(
StreamInfo* stream_info);
48 Status SetupProtectionPattern(StreamType stream_type);
50 bool EncryptVpxFrame(
const std::vector<VPxFrameInfo>& vpx_frames,
54 void EncryptBytes(uint8_t* data,
size_t size);
57 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
58 void InjectVideoSliceHeaderParserForTesting(
59 std::unique_ptr<VideoSliceHeaderParser> header_parser);
62 const FourCC protection_scheme_ = FOURCC_NULL;
64 std::string stream_label_;
66 std::shared_ptr<EncryptionConfig> encryption_config_;
67 std::unique_ptr<AesCryptor> encryptor_;
68 Codec codec_ = kUnknownCodec;
71 uint8_t nalu_length_size_ = 0;
73 size_t leading_clear_bytes_size_ = 0;
75 size_t min_protected_data_size_ = 0;
77 int64_t remaining_clear_lead_ = 0;
79 uint64_t crypto_period_duration_ = 0;
81 int64_t prev_crypto_period_index_ = -1;
82 bool check_new_crypto_period_ =
false;
85 uint8_t crypt_byte_block_ = 0;
87 uint8_t skip_byte_block_ = 0;
90 std::unique_ptr<VPxParser> vpx_parser_;
92 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
98 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_