EDA.Voice.Audio (EDA v0.3.0)

Copy Markdown View Source

Handles UDP socket management, IP discovery, audio encoding via FFmpeg, and the player loop for sending opus frames over RTP.

Summary

Functions

Receives count voice packets from the UDP socket.

Opens a UDP socket and performs IP discovery against the voice server.

Starts playing audio from the given input. Runs as a linked process.

Functions

listen(socket, secret_key, mode, count)

@spec listen(port(), binary(), String.t(), integer()) :: [{integer(), binary()}]

Receives count voice packets from the UDP socket.

Returns a list of {ssrc, opus_data} tuples.

open_udp_and_discover(ip, port, ssrc)

@spec open_udp_and_discover(String.t(), integer(), integer()) ::
  {:ok, port(), String.t(), integer()} | {:error, term()}

Opens a UDP socket and performs IP discovery against the voice server.

Returns {:ok, socket, our_ip, our_port} or {:error, reason}.

play(guild_id, input, type, voice_state, opts \\ [])

@spec play(String.t(), String.t() | Enumerable.t(), atom(), map(), keyword()) :: pid()

Starts playing audio from the given input. Runs as a linked process.

Types:

  • :url - URL or file path passed to ffmpeg
  • :raw - Raw opus frames (binary stream)

Returns the pid of the player process.