Interface DaveSession
- See Also:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumCodec used for encoded framesstatic enumMediaType used by transmissions -
Method Summary
Modifier and TypeMethodDescriptionvoidaddUser(long userId) Add a new recognized user for the MLS group.voidassignSsrcToCodec(DaveSession.Codec codec, int ssrc) Associates a mediaDaveSession.Codecwith a given SSRC (synchronization source).booleandecrypt(DaveSession.MediaType mediaType, long userId, ByteBuffer encrypted, ByteBuffer decrypted) Decrypts an Opus-encoded audio frame received from the network.voiddestroy()Called when the session is no longer needed and all related resources should be cleaned up.booleanencrypt(DaveSession.MediaType mediaType, int ssrc, ByteBuffer data, ByteBuffer encrypted) Encrypts the plaintext frame and writes the encrypted data intoencrypted.intgetMaxDecryptedFrameSize(DaveSession.MediaType type, long userId, int frameSize) Calculate the maximum decrypted size for the provided frame.intgetMaxEncryptedFrameSize(DaveSession.MediaType type, int frameSize) Calculate the maximum encrypted size for the provided frame.intThe maximum supported version of the DAVE protocol.voidCalled when the connection is established.voidonDaveProtocolExecuteTransition(int transitionId) HandleDAVE_PROTOCOL_EXECUTE_TRANSITION(opcode22).voidonDaveProtocolMLSExternalSenderPackage(ByteBuffer externalSenderPackage) HandleMLS_EXTERNAL_SENDER_PACKAGE(opcode25).voidonDaveProtocolPrepareEpoch(long epoch, int protocolVersion) HandleDAVE_PROTOCOL_PREPARE_EPOCH(opcode24).voidonDaveProtocolPrepareTransition(int transitionId, int protocolVersion) HandleDAVE_PROTOCOL_PREPARE_TRANSITION(opcode21).voidonMLSPrepareCommitTransition(int transitionId, ByteBuffer commit) HandleMLS_PREPARE_COMMIT_TRANSITION(opcode29).voidonMLSProposals(ByteBuffer proposals) HandleMLS_PROPOSALS(opcode27).voidonMLSWelcome(int transitionId, ByteBuffer welcome) HandleMLS_WELCOME(opcode30).voidonSelectProtocolAck(int protocolVersion) HandleSELECT_PROTOCOL_ACK/SESSION_DESCRIPTION(opcode4).voidremoveUser(long userId) Remove a user from the MLS group.
-
Method Details
-
getMaxProtocolVersion
int getMaxProtocolVersion()The maximum supported version of the DAVE protocol.- Returns:
- Maximum supported version
-
getMaxEncryptedFrameSize
Calculate the maximum encrypted size for the provided frame.This is used to ensure the
ByteBufferprovided toencrypt(MediaType, int, ByteBuffer, ByteBuffer)has enough space for the encrypted data.- Parameters:
type- TheDaveSession.MediaTypeof the frameframeSize- The size of the encoded frame- Returns:
- The maximum number of bytes an encrypted frame will need
-
getMaxDecryptedFrameSize
Calculate the maximum decrypted size for the provided frame.This is used to ensure the
ByteBufferprovided todecrypt(MediaType, long, ByteBuffer, ByteBuffer)has enough space for the decrypted data.- Parameters:
type- TheDaveSession.MediaTypeof the frameuserId- The id for the user that sent this frameframeSize- The size of the encrypted frame- Returns:
- The maximum number of bytes a decrypted frame will need
-
assignSsrcToCodec
Associates a mediaDaveSession.Codecwith a given SSRC (synchronization source).This mapping is used by the implementation to select the correct codec for incoming or outgoing media identified by the specified
ssrc.- Parameters:
codec- The codec that should be used for the given SSRCssrc- The SSRC value provided by the voice gateway
-
encrypt
boolean encrypt(@Nonnull DaveSession.MediaType mediaType, int ssrc, @Nonnull ByteBuffer data, @Nonnull ByteBuffer encrypted) Encrypts the plaintext frame and writes the encrypted data intoencrypted.Implementations should read the remaining bytes from
datastarting at its current position, and write the resulting encrypted payload intoencryptedstarting at its current position.The caller is responsible for ensuring that
encryptedhas sufficient remaining capacity to receive the encrypted frame, which can be determined viagetMaxEncryptedFrameSize(MediaType, int).After successfully encrypting the data, the
encryptedbuffer should have its position at the beginning of the encrypted data and its limit at the end of the encrypted data. (Usually achieved by callingBuffer.flip())- Parameters:
mediaType- The media type of thedatassrc- The SSRC (synchronization source) of the senderdata- The direct buffer containing the data to encryptencrypted- The direct buffer to fill with the encrypted data (with enough space for max encrypted frame size).- Returns:
- True, if the encryption was successful
-
decrypt
boolean decrypt(@Nonnull DaveSession.MediaType mediaType, long userId, @Nonnull ByteBuffer encrypted, @Nonnull ByteBuffer decrypted) Decrypts an Opus-encoded audio frame received from the network.Implementations should read the remaining bytes from
encryptedstarting at its current position, and write the resulting decrypted payload intodecryptedstarting at its current position.The caller is responsible for ensuring that
decryptedhas sufficient remaining capacity to receive the decrypted frame, which can be determined viagetMaxDecryptedFrameSize(MediaType, long, int).After successfully decrypting the data, the
decryptedbuffer should have its position at the beginning of the decrypted data and its limit at the end of the decrypted data. (Usually achieved by callingBuffer.flip())- Parameters:
mediaType- The media type of theencrypteddatauserId- The id for the user that sent this frameencrypted- The direct buffer containing encrypted datadecrypted- The direct buffer to fill with the decrypted data (with enough space for max decrypted frame size)- Returns:
- True, if the decryption was successful
-
addUser
void addUser(long userId) Add a new recognized user for the MLS group.- Parameters:
userId- The user id of the new member- See Also:
-
removeUser
void removeUser(long userId) Remove a user from the MLS group.- Parameters:
userId- The user id to remove- See Also:
-
initialize
void initialize()Called when the connection is established.Can be used to track timeouts before the first call to
onSelectProtocolAck(int). -
destroy
void destroy()Called when the session is no longer needed and all related resources should be cleaned up. -
onSelectProtocolAck
void onSelectProtocolAck(int protocolVersion) HandleSELECT_PROTOCOL_ACK/SESSION_DESCRIPTION(opcode4).- Parameters:
protocolVersion- The protocol version to transition to- See Also:
-
onDaveProtocolPrepareTransition
void onDaveProtocolPrepareTransition(int transitionId, int protocolVersion) HandleDAVE_PROTOCOL_PREPARE_TRANSITION(opcode21).Sent when a protocol transition should be prepared. Followed by
onDaveProtocolExecuteTransition(int)once all group members are ready for transition- Parameters:
transitionId- The transition id, to be referenced later byonDaveProtocolExecuteTransition(int)protocolVersion- The target protocol version to transition to- See Also:
-
onDaveProtocolExecuteTransition
void onDaveProtocolExecuteTransition(int transitionId) HandleDAVE_PROTOCOL_EXECUTE_TRANSITION(opcode22).Sent when a transition should be executed. This is usually preceded by
onDaveProtocolPrepareTransition(int, int).- Parameters:
transitionId- The transition id, previously registered byonDaveProtocolPrepareTransition(int, int)- See Also:
-
onDaveProtocolPrepareEpoch
void onDaveProtocolPrepareEpoch(long epoch, int protocolVersion) HandleDAVE_PROTOCOL_PREPARE_EPOCH(opcode24).Sent from the server to clients to announce upcoming protocol version changes. When the epoch ID is equal to 1, this message indicates that a new MLS group is to be created for the given protocol version.
- Parameters:
epoch- The epoch used by the session (equal to1to indicate a new MLS group should be created)protocolVersion- The protocol version for the new MLS group- See Also:
-
onDaveProtocolMLSExternalSenderPackage
HandleMLS_EXTERNAL_SENDER_PACKAGE(opcode25).Includes the basic credential and public key for the voice gateway external sender to be added to the MLS group's extensions.
- Parameters:
externalSenderPackage- Binary representation for the external sender package- See Also:
-
onMLSProposals
HandleMLS_PROPOSALS(opcode27).Includes a list of proposals to be appended or a list of proposal refs to be revoked.
- Parameters:
proposals- Binary representation for the proposals- See Also:
-
onMLSPrepareCommitTransition
HandleMLS_PREPARE_COMMIT_TRANSITION(opcode29).Includes the MLS commit being broadcast to move to the next epoch.
- Parameters:
transitionId- The transition id for the commit transitioncommit- Binary representation of the commit message- See Also:
-
onMLSWelcome
HandleMLS_WELCOME(opcode30).Includes the MLS Welcome which adds the pending member to the group
- Parameters:
transitionId- The transition id for the welcome transitionwelcome- Binary representation of the welcome message- See Also:
-