# `Octoroom.Outlet`
[🔗](https://github.com/samrat/octoroom/blob/v0.1.0/lib/octoroom/outlet.ex#L1)

One worker output track. Paces audio to real time and sends it, Opus
encoded, through the worker's peer connection: Cloudflare forwards
whatever it is sent, so anything sent early would still play after a
barge-in.

Workers queue room PCM (48 kHz stereo s16le) with `play/3`. Every 20 ms
the outlet sends the next whole frame and sends nothing when the queue is
empty. `flush/2` empties the queue, so at most one frame plus the network
is already on its way, and says how much audio it dropped: what was
queued minus that is what listeners heard. Audio played before the track is pushed and its
connection is up is dropped as it comes due, as a live stream would be.

Once its connection is up, the outlet sends one frame of silence, so
Cloudflare keeps the track however long the worker stays quiet. The first
frame sent tells the room server the track is live, so listeners can
pull it. The outlet is separate from its worker: if the
worker crashes, the track stays published.

# `child_spec`

Returns a specification to start this module under a supervisor.

See `Supervisor`.

# `flush`

Drops an output track's queued, unplayed audio. Returns how many ms of
audio it dropped, or nil if the outlet isn't running.

# `play`

Queues room PCM on an output track. A no-op if the outlet isn't running.

# `start_link`

# `stats`

`%{queued_ms, sent, dropped, underruns, connected, live}` for an output
track, or nil if it isn't running. `underruns` counts the times the queue
ran dry while playing.

# `via`

# `whereis`

---

*Consult [api-reference.md](api-reference.md) for complete listing*
