Documentation
¶
Overview ¶
Package broadcast streams the player's audio into a Discord voice channel.
Package stream sends an engine's output to a Discord voice socket as Opus, paced by the wall clock: shared by dotamp's broadcast and the house bot.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrSetup = errors.New("stream setup")
ErrSetup wraps a failure to build the Opus encoder.
var Silence = []byte{0xF8, 0xFF, 0xFE}
Silence is the Opus packet Discord documents for keeping a stream warm while nothing plays.
Functions ¶
func Drain ¶
func Drain(stop <-chan struct{}, udp UDP)
Drain reads and discards incoming packets until stop closes or Read fails, so the socket never backs up.
func EncodeLoop ¶ added in v0.20.0
EncodeLoop encodes the feed to Opus, one 20 ms packet per slot, paced by the wall clock, and hands each packet to emit. When the feed has no audio (paused, between songs) it encodes silence, so a listener's stream never goes idle. It returns when stop closes.
Types ¶
type OggWriter ¶ added in v0.20.0
type OggWriter struct {
// contains filtered or unexported fields
}
OggWriter frames Opus packets as an Ogg Opus stream (RFC 7845): an OpusHead page, an OpusTags page, then one packet per page. Each writer is a complete stream of its own, so a listener joining late still gets a well-formed file.
func NewOggWriter ¶ added in v0.20.0
func (*OggWriter) WriteHeaders ¶ added in v0.20.0
WriteHeaders writes the identification and comment headers.
type Pacer ¶
type Pacer struct {
// contains filtered or unexported fields
}
Pacer hands out 20 ms slots against the wall clock, so a late tick sends what it owes instead of letting the stream slip behind one slot per miss.
type Pipeline ¶
type Pipeline struct {
// contains filtered or unexported fields
}
Pipeline turns engine-rate stereo float32 into 20 ms Opus packets.
func NewPipeline ¶
type Speaker ¶
type Speaker struct {
// contains filtered or unexported fields
}
Speaker decides, tick by tick, whether to send audio, one of Discord's silence frames, or nothing. The speaking flag is set once at join and never dropped: clearing it and raising it again was found to kill the stream on Discord's side (live test, 2026-10-17), while a run of silence frames followed by nothing resumes cleanly.