Package moe.kyokobot.libdave
Interface Encryptor
- All Superinterfaces:
AutoCloseable
- All Known Subinterfaces:
NettyEncryptor
Handles the encryption of outbound media frames using DAVE.
The Encryptor uses the local user's KeyRatchet to encrypt frames before they are sent.
-
Method Summary
Modifier and TypeMethodDescriptionvoidassignSsrcToCodec(int ssrc, Codec codec) Assigns an SSRC (Synchronization Source identifier) to a specific codec.voidclose()intEncrypts a media frame.intencrypt(MediaType mediaType, int ssrc, ByteBuffer frame, ByteBuffer encryptedFrame) Encrypts a media frame into NIO ByteBuffer.default intgetMaxCiphertextByteSize(MediaType mediaType, int frameSize) Calculates the maximum possible size of the ciphertext (encrypted) frame for a given plaintext frame size.intGets the current protocol version used by the encryptor.voidsetKeyRatchet(KeyRatchet keyRatchet) Sets the key ratchet to be used for encryption.voidsetPassthroughMode(boolean passthroughMode) Sets whether the encryptor should operate in passthrough mode.voidSets a callback to be notified when the protocol version changes.
-
Method Details
-
setKeyRatchet
Sets the key ratchet to be used for encryption.This typically corresponds to the local user's ratchet derived from the session.
- Parameters:
keyRatchet- The key ratchet.
-
setPassthroughMode
void setPassthroughMode(boolean passthroughMode) Sets whether the encryptor should operate in passthrough mode.- Parameters:
passthroughMode-trueto enable passthrough,falseto disable.
-
assignSsrcToCodec
Assigns an SSRC (Synchronization Source identifier) to a specific codec.This helps the encryptor understand how to parse and encrypt frames for a given stream.
- Parameters:
ssrc- The SSRC identifier.codec- The codec used for this SSRC.
-
getProtocolVersion
int getProtocolVersion()Gets the current protocol version used by the encryptor.- Returns:
- The protocol version.
-
getMaxCiphertextByteSize
Calculates the maximum possible size of the ciphertext (encrypted) frame for a given plaintext frame size.- Parameters:
mediaType- The type of media.frameSize- The size of the plaintext frame.- Returns:
- The maximum size of the encrypted frame in bytes.
-
encrypt
Encrypts a media frame.- Parameters:
mediaType- The type of media.ssrc- The SSRC of the stream.frame- The input buffer containing the plaintext frame.encryptedFrame- The output buffer to write the encrypted frame into.- Returns:
- The number of bytes written to
encryptedFrameon success, or a negative error code (seeEncryptorResultCode) on failure.
-
encrypt
Encrypts a media frame into NIO ByteBuffer.- Parameters:
mediaType- The type of media.ssrc- The SSRC of the stream.frame- The input ByteBuffer containing the plaintext frame.encryptedFrame- The output ByteBuffer to write the encrypted frame into.- Returns:
- The number of bytes written to
encryptedFrameon success, or a negative error code on failure.
-
setProtocolVersionChangedCallback
Sets a callback to be notified when the protocol version changes.- Parameters:
callback- The callback listener.
-
close
void close()- Specified by:
closein interfaceAutoCloseable
-