Module upload

Module upload 

Source
Expand description

Rdio API upload queue processor.

Polls the streams table for completed voice recordings with upload_status = 'pending' and uploads them to an SDRTrunk-compatible Rdio Scanner API server using the POST /api/call-upload multipart/form-data protocol.

The protocol wire format — field names, the User-Agent: sdrtrunk header, the "Call imported successfully." success marker — lives in rdio. This module is the orchestrator: it drains the database queue, maps StreamRow fields onto the Rdio field set, calls rdio::upload_stream for each row, and transitions the row through the upload lifecycle.

§Lifecycle transitions

For every pending row returned by crate::db::uploads::get_pending the processor:

§System id scheme

Rdio Scanner expects every system to be numeric, but D-STAR reflector names are alphabetic with a numeric suffix (REF030, DCS030, …). To disambiguate reflectors that share a numeric suffix across protocol families we prefix the numeric suffix with a protocol tag:

ProtocolBaseExampleResulting id
dplus (REF)10_000REF03010030
dextra (XLX)20_000XLX03020030
dcs (DCS)30_000DCS03030030
dextra (XRF)40_000XRF03040030

Pi-Star labels XLX and XRF reflectors identically as dextra; we distinguish them by the 3-letter prefix on the reflector callsign.

§Talkgroup scheme

Rdio Scanner talkgroups are numeric; D-STAR modules are letters A-Z. We map A → 1, B → 2, …, Z → 26. Unknown module letters fall back to 0.

Modules§

rdio 🔒
SDRTrunk-compatible Rdio API multipart upload client.

Constants§

BATCH_SIZE 🔒
Maximum number of pending rows to drain per tick.

Functions§

compute_system_id 🔒
Returns the Rdio Scanner system id for a given D-STAR reflector.
handle_upload_failure 🔒
Handles an upload failure by deciding whether to retry or mark the row as permanently failed, based on the attempts-so-far counter.
make_audio_name 🔒
Builds the audio part’s filename.
make_talker_alias 🔒
Builds the talkerAlias field from a callsign and optional suffix.
module_to_talkgroup 🔒
Returns the Rdio Scanner talkgroup id for a D-STAR module letter.
numeric_suffix 🔒
Extracts the trailing numeric suffix of a reflector callsign.
process_one 🔒
Uploads a single stream and records the outcome.
process_pending 🔒
Drains one batch of pending uploads.
protocol_label 🔒
Returns the human-readable protocol label used in systemLabel.
reflector_prefix 🔒
Returns the first three ASCII-uppercase letters of a reflector name, or None if the prefix is shorter than three bytes or contains non-ASCII.
run 🔒
Runs the upload queue processor loop.