godave

package module
v0.0.0-...-4c5fc93 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2026 License: Apache-2.0 Imports: 1 Imported by: 0

README

Go Reference Go Report Go Version License GoDave Version DisGo Discord

discord gopher

GoDave

GoDave is a library that provides Go bindings for libdave and provides a generic DAVE interface allowing for different implementations in the future.

Summary

  1. Libdave Installation
  2. Installation Script (Recommended)
  3. Manual Build
  4. Example Usage
  5. License

Libdave Installation

This library uses CGO and dynamic linking to use libdave. As such, it needs to be installed in the system beforehand to build this library.

[!NOTE] Due to the nature of this project, it might be necessary to re-install libdave when updating to a new GoDave version.

Versions requiring this will be denoted with a bump in the major version (for reference: major.minor.patch).

We provide helpful scripts in scripts/ to simplify installing a compatible libdave version. Grab whichever one is applicable to your OS (.sh for Linux and MacOS; ps1 for Windows PowerShell) and (after auditing its contents) run it and follow any instructions it might output.

Once that step is complete, you can continue with the installation of GoDave.

Manual Build

For a manual build, please clone https://github.com/discord/libdave and use revision 74979cb33febf4ddef0c2b66e57520b339550c17.

[!NOTE] We provide no guarantees for this version of GoDave to run for other revisions other than that the one mentioned above.

As the library evolves and new versions of libdave are released, the above revision will be updated to match the GoDave version

Once checked out, please follow the build instructions and setup the appropriate pkg-config file and configuration to allow for discovery at compilation time.

Example Usage

For an example of how to use GoDave, please see here

License

Distributed under the License. See LICENSE for more information.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Callbacks

type Callbacks interface {
	// SendMLSKeyPackage sends a MLS Key Package to the voice gateway.
	SendMLSKeyPackage(mlsKeyPackage []byte) error
	// SendMLSCommitWelcome sends a MLS Commit Welcome to the voice gateway.
	SendMLSCommitWelcome(mlsCommitWelcome []byte) error
	// SendReadyForTransition notifies the voice gateway that the client is ready for the transition.
	SendReadyForTransition(transitionID uint16) error
	// SendInvalidCommitWelcome notifies the voice gateway that the commit welcome is invalid.
	SendInvalidCommitWelcome(transitionID uint16) error
}

Callbacks represents the callbacks used by a DAVE session to send messages back to the voice gateway.

type ChannelID

type ChannelID uint64

type Codec

type Codec int

Codec represents an audio codec used in the DAVE protocol.

const (
	// CodecOpus represents the OPUS audio codec.
	CodecOpus Codec = 1
)

type Session

type Session interface {
	// MaxSupportedProtocolVersion returns the maximum supported DAVE version for this session.
	MaxSupportedProtocolVersion() int

	// SetChannelID sets the channel ID for this session.
	SetChannelID(channelID ChannelID)

	// AssignSsrcToCodec maps a given SSRC to a specific Codec.
	AssignSsrcToCodec(ssrc uint32, codec Codec)

	// MaxEncryptedFrameSize returns the maximum size of an encrypted OPUS frame given the frame size.
	MaxEncryptedFrameSize(frameSize int) int

	// Encrypt encrypts an OPUS frame.
	Encrypt(ssrc uint32, frame []byte, encryptedFrame []byte) (int, error)

	// MaxDecryptedFrameSize returns the maximum size of a decrypted OPUS frame given the frame size.
	MaxDecryptedFrameSize(userID UserID, frameSize int) int

	// Decrypt decrypts an OPUS frame.
	Decrypt(userID UserID, frame []byte, decryptedFrame []byte) (int, error)

	// AddUser adds a user to the MLS group.
	AddUser(userID UserID)

	// RemoveUser removes a use from the MLS group.
	RemoveUser(userID UserID)

	// OnSelectProtocolAck is to be called when SELECT_PROTOCOL_ACK (4) is received.
	OnSelectProtocolAck(protocolVersion uint16)

	// OnDavePrepareTransition is to be called when DAVE_PROTOCOL_PREPARE_TRANSITION (21) is received.
	OnDavePrepareTransition(transitionID uint16, protocolVersion uint16)

	// OnDaveExecuteTransition is to be called when DAVE_PROTOCOL_EXECUTE_TRANSITION (22) is received.
	OnDaveExecuteTransition(protocolVersion uint16)

	// OnDavePrepareEpoch is to be called when DAVE_PROTOCOL_PREPARE_EPOCH (24) is received.
	OnDavePrepareEpoch(epoch int, protocolVersion uint16)

	// OnDaveMLSExternalSenderPackage is to be called when DAVE_MLS_EXTERNAL_SENDER_PACKAGE (25) is received.
	OnDaveMLSExternalSenderPackage(externalSenderPackage []byte)

	// OnDaveMLSProposals is to be called when DAVE_MLS_PROPOSALS (27) is received.
	OnDaveMLSProposals(proposals []byte)

	// OnDaveMLSPrepareCommitTransition is to be called when DAVE_MLS_ANNOUNCE_COMMIT_TRANSITION (29) is received.
	OnDaveMLSPrepareCommitTransition(transitionID uint16, commitMessage []byte)

	// OnDaveMLSWelcome is to be called when DAVE_MLS_WELCOME (30) is received.
	OnDaveMLSWelcome(transitionID uint16, welcomeMessage []byte)
}

Session is an interface representing a DAVE session. Implementations of this interface should handle encryption, decryption, and DAVE protocol events.

func NewNoopSession

func NewNoopSession(logger *slog.Logger, _ UserID, _ Callbacks) Session

type SessionCreateFunc

type SessionCreateFunc func(logger *slog.Logger, userID UserID, callbacks Callbacks) Session

SessionCreateFunc is an agnostic function type for creating DAVE sessions.

type UserID

type UserID string

Directories

Path Synopsis
golibdave module
libdave module

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL