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 bool SampleAesEncryptEac3Frame(
const uint8_t* source,
70 void EncryptBytes(
const uint8_t* source,
size_t source_size, uint8_t* dest);
75 bool ExtractEac3SyncframeSizes(
const uint8_t* source,
77 std::vector<size_t>* syncframe_sizes);
80 void InjectVpxParserForTesting(std::unique_ptr<VPxParser> vpx_parser);
81 void InjectVideoSliceHeaderParserForTesting(
82 std::unique_ptr<VideoSliceHeaderParser> header_parser);
85 const FourCC protection_scheme_ = FOURCC_NULL;
87 std::string stream_label_;
89 std::shared_ptr<EncryptionConfig> encryption_config_;
90 std::unique_ptr<AesCryptor> encryptor_;
91 Codec codec_ = kUnknownCodec;
94 uint8_t nalu_length_size_ = 0;
96 size_t leading_clear_bytes_size_ = 0;
100 size_t min_protected_data_size_ = 0;
102 int64_t remaining_clear_lead_ = 0;
104 uint64_t crypto_period_duration_ = 0;
106 int64_t prev_crypto_period_index_ = -1;
107 bool check_new_crypto_period_ =
false;
110 uint8_t crypt_byte_block_ = 0;
112 uint8_t skip_byte_block_ = 0;
115 std::unique_ptr<VPxParser> vpx_parser_;
117 std::unique_ptr<VideoSliceHeaderParser> header_parser_;
123 #endif // PACKAGER_MEDIA_CRYPTO_ENCRYPTION_HANDLER_H_
All the methods that are virtual are virtual for mocking.