EncryptsHLSSegments
Table of Contents
Properties
- $encryptionIV : string
- Encryption IV
- $encryptionKey : string
- The encryption key.
- $encryptionKeyFilename : string
- The encryption key filename.
- $encryptionSecretsRoot : mixed
- Disk to store the secrets.
- $listener : StdListener
- Listener that will rotate the key.
- $nextEncryptionFilenameAndKey : array<string|int, mixed>
- A fresh filename and encryption key for the next round.
- $onNewEncryptionKey : callable
- Gets called whenever a new encryption key is set.
- $rotateEncryptiongKey : bool
- Wether to rotate the key on every segment.
- $segmentsOpened : int
- Number of opened segments.
- $segmentsPerKey : int
- Number of segments that can use the same key.
Methods
- generateEncryptionKey() : string
- Creates a new encryption key.
- generateEncryptionKeyFilename() : string
- Creates a new encryption key filename.
- withEncryptionKey() : HLSExporter|EncryptsHLSSegments
- Initialises the disk, info and IV for encryption and sets the key.
- withRotatingEncryptionKey() : HLSExporter|EncryptsHLSSegments
- Enables encryption with rotating keys. The callable will receive every new key and the integer sets the number of segments that can use the same key.
- addHandlerToRotateEncryptionKey() : void
- Adds a listener and handler to rotate the key on every new HLS segment.
- cleanupHLSEncryption() : HLSExporter|EncryptsHLSSegments
- Removes the encryption keys from the temporary disk.
- getEncrypedHLSParameters() : array<string|int, mixed>
- Returns an array with the encryption parameters.
- removeHandlerThatRotatesEncryptionKey() : HLSExporter|EncryptsHLSSegments
- Remove the listener at the end of the export to prevent duplicate event handlers.
- replaceAbsolutePathsHLSEncryption() : HLSExporter|EncryptsHLSSegments
- While encoding, the encryption keys are saved to a temporary directory.
- rotateEncryptionKey() : string
- Rotates the key and returns the absolute path to the info file. This method should be executed as fast as possible, or we might be too late for FFmpeg opening the next segment. That's why we don't use the Disk-class magic.
Properties
$encryptionIV
Encryption IV
private
string
$encryptionIV
$encryptionKey
The encryption key.
private
string
$encryptionKey
$encryptionKeyFilename
The encryption key filename.
private
string
$encryptionKeyFilename
$encryptionSecretsRoot
Disk to store the secrets.
private
mixed
$encryptionSecretsRoot
$listener
Listener that will rotate the key.
private
StdListener
$listener
$nextEncryptionFilenameAndKey
A fresh filename and encryption key for the next round.
private
array<string|int, mixed>
$nextEncryptionFilenameAndKey
$onNewEncryptionKey
Gets called whenever a new encryption key is set.
private
callable
$onNewEncryptionKey
$rotateEncryptiongKey
Wether to rotate the key on every segment.
private
bool
$rotateEncryptiongKey
= false
$segmentsOpened
Number of opened segments.
private
int
$segmentsOpened
= 0
$segmentsPerKey
Number of segments that can use the same key.
private
int
$segmentsPerKey
= 1
Methods
generateEncryptionKey()
Creates a new encryption key.
public
static generateEncryptionKey() : string
Return values
stringgenerateEncryptionKeyFilename()
Creates a new encryption key filename.
public
static generateEncryptionKeyFilename() : string
Return values
stringwithEncryptionKey()
Initialises the disk, info and IV for encryption and sets the key.
public
withEncryptionKey(string $key[, string $filename = 'secret.key' ]) : HLSExporter|EncryptsHLSSegments
Parameters
- $key : string
- $filename : string = 'secret.key'
Return values
HLSExporter|EncryptsHLSSegmentswithRotatingEncryptionKey()
Enables encryption with rotating keys. The callable will receive every new key and the integer sets the number of segments that can use the same key.
public
withRotatingEncryptionKey(Closure $callback[, int $segmentsPerKey = 1 ]) : HLSExporter|EncryptsHLSSegments
Parameters
- $callback : Closure
- $segmentsPerKey : int = 1
Return values
HLSExporter|EncryptsHLSSegmentsaddHandlerToRotateEncryptionKey()
Adds a listener and handler to rotate the key on every new HLS segment.
private
addHandlerToRotateEncryptionKey() : void
cleanupHLSEncryption()
Removes the encryption keys from the temporary disk.
private
cleanupHLSEncryption() : HLSExporter|EncryptsHLSSegments
Return values
HLSExporter|EncryptsHLSSegmentsgetEncrypedHLSParameters()
Returns an array with the encryption parameters.
private
getEncrypedHLSParameters() : array<string|int, mixed>
Return values
array<string|int, mixed>removeHandlerThatRotatesEncryptionKey()
Remove the listener at the end of the export to prevent duplicate event handlers.
private
removeHandlerThatRotatesEncryptionKey() : HLSExporter|EncryptsHLSSegments
Return values
HLSExporter|EncryptsHLSSegmentsreplaceAbsolutePathsHLSEncryption()
While encoding, the encryption keys are saved to a temporary directory.
private
replaceAbsolutePathsHLSEncryption(Collection $playlistMedia) : HLSExporter|EncryptsHLSSegments
With this method, we loop through all segment playlists and replace the absolute path to the keys to a relative ones.
Parameters
- $playlistMedia : Collection
Return values
HLSExporter|EncryptsHLSSegmentsrotateEncryptionKey()
Rotates the key and returns the absolute path to the info file. This method should be executed as fast as possible, or we might be too late for FFmpeg opening the next segment. That's why we don't use the Disk-class magic.
private
rotateEncryptionKey() : string