Calls and media

Voice rooms, one picture per listener, calls between two people, and the one port that carries them.

How a call travels

Chat and call setup go over the live socket, through the tunnel or your proxy. Call audio and video do not fit through the tunnel, so they go straight to the server on one port number: UDP first, and TCP on the same number for networks that block UDP.

The server is a selective forwarding unit. It passes each person’s Opus audio and H.264 video on to the others and never re-encodes them. Nothing is recorded or stored. Calls live in memory, so a restart ends them and the apps rejoin.

Open the media port

  1. Set TINYSERVER_PUBLIC_IP in the environment file to the address members reach: the router’s public IPv4 address. The server does not guess it.
  2. TINYSERVER_MEDIA_PORT is 50000 unless set. Compose publishes the same number inside and out, on UDP and TCP.
  3. On the router, forward that port to the host, both UDP and TCP.
  4. On the host firewall, allow it for both. With the default port and ufw: ufw allow 50000/udp and ufw allow 50000/tcp.
  5. Optional: set TINYSERVER_LAN_IP to the host’s address on the home network, such as 192.168.1.20. Many routers do not let a member at home reach the public address from inside; with this set, the server offers them the LAN address too.
  6. docker compose up -d, then open /health on the chat hostname. It says "media": "up" and lists "transports": ["udp", "tcp"], with "lan" when step 5 is set.

Without TINYSERVER_PUBLIC_IP the server still runs. /health says "media": "off", and a call has no audio or video.

Members see the host’s address. Every member in a call is sent TINYSERVER_PUBLIC_IP. The tunnel does not hide the host’s address from members. Members do not learn each other’s addresses from the server.

A stranger who finds the port gets a reply to a connectivity check and nothing else: no media is processed without the per-join password, which travels only over the signed-in live socket.

What is not built

Upload budget

Set TINYSERVER_MEDIA_EGRESS_KBPS to what the host can upload for calls, in kb/s, such as 8000 on a 10 Mb/s line. The server plans every call together to fit it: screen shares first, then everyone gets the high camera layer if that fits, else the low one, else audio only.

Each listener with a camera to watch costs about 1,200 kb/s on the high layer and 350 on the low one, and each voice about 50. Without a budget, nothing stops a large room sending more than the line carries, and everyone’s audio suffers along with the video.

On a VPS

A small VPS drops call packets long before its CPU is busy, because the kernel’s socket buffer limits are low. The media socket asks for 4 MiB of buffer each way, and a stock Linux kernel silently caps that at about 200 KiB. These are host settings; a container cannot change them. On the host:

printf 'net.core.rmem_max=4194304\nnet.core.wmem_max=4194304\n' | sudo tee /etc/sysctl.d/90-tinyserver-media.conf
sudo sysctl --system

Restart tinyserver afterwards. Its log says media socket buffers with what it got; Linux reports double the usable size, so about 8388608 each way means the setting took.

Set the upload budget a little under what the plan really sustains, not its burst figure.

Once a minute during a call the log has a media counters line:

FieldWhat it tells you
send_droppedAbove zero: the host could not keep up
longest_turn_msAbove about 20: the media thread was short of CPU
longest_gap_msWell over 50: the thread, or the whole VM, was not running
audio_late_msHow late audio reached the server. It measures the path to the server, not the server.
tcp_sentAbove zero: someone’s media is on TCP

TCP streams are capped at 256 in all and 16 from one address. One that sends nothing for a call within 5 seconds, or nothing at all for 30, is closed.

Voice rooms

A room is a voice channel people drop into; nobody is rung. A person is in one call at a time, and joining another leaves the first.

SettingRangeNotes
User limit0 to 990 means the server’s limit for a room
Bitrate16 to 128 kb/s, 64 unless setWhat each app encodes its voice at
Push to talk onlyon or offKept by the server and honoured by the app; the server does not check it
Videoon or offThe same: honoured by the app
Require end-to-end encryptionon or offThe server refuses an app that cannot. End-to-end encryption.

How many people a room and a server hold is set by the operator: TINYSERVER_CALL_ROOM_MAX, 12 unless set, and TINYSERVER_CALL_SERVER_MAX, 32 unless set. Size them to what the host and its line carry. A room’s own user limit can lower its number and never raises it past the server’s.

Room permissions decide who may join and who may speak. Someone without the speak permission joins and listens; their audio is not forwarded. Moderators can server mute, server deafen, move and disconnect people. A timeout or a ban ends the person’s call.

A dropped connection keeps its seat for 10 seconds. After 15 seconds with no media at all, the server ends that person’s seat.

One picture

Each listener gets everyone else’s audio and at most one video: the room’s screen share while someone else is sharing, otherwise one camera, the active speaker’s when it is live. A listener is never sent their own picture.

Calls between two people

A member can call another from their direct conversation. It rings for 30 seconds. Only the two people see it, and it ends for both when one leaves. The conversation keeps whether the call was missed, declined, cancelled or ended, with no duration. A room’s encryption setting does not apply: the call is end-to-end encrypted when both apps can.

There are no group calls outside rooms.

Edit this page on GitHub