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"
17 class VideoSliceHeaderParser;
57 Status Process(std::unique_ptr<StreamData> stream_data)
override;
61 friend class EncryptionHandlerTest;
71 Status SetupProtectionPattern(StreamType stream_type);
73 bool EncryptVpxFrame(
const std::vector<VPxFrameInfo>& vpx_frames,
77 void EncryptBytes(uint8_t* data,
size_t size);
80 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
81 void InjectVideoSliceHeaderParserForTesting(
82 std::unique_ptr<VideoSliceHeaderParser> header_parser);
86 KeySource::TrackType track_type_ = KeySource::TRACK_TYPE_UNKNOWN;
88 std::shared_ptr<EncryptionConfig> encryption_config_;
89 std::unique_ptr<AesCryptor> encryptor_;
90 Codec codec_ = kUnknownCodec;
93 uint8_t nalu_length_size_ = 0;
95 size_t leading_clear_bytes_size_ = 0;
97 size_t min_protected_data_size_ = 0;
99 int64_t remaining_clear_lead_ = 0;
101 uint64_t crypto_period_duration_ = 0;
103 int64_t prev_crypto_period_index_ = -1;
104 bool check_new_crypto_period_ =
false;
107 uint8_t crypt_byte_block_ = 0;
109 uint8_t skip_byte_block_ = 0;
112 std::unique_ptr<VPxParser> vpx_parser_;
114 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
120 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_