Workflow: Receiving Audio by Using the Oracle Radio WebSocket API

Subscribe to a Radio channel, establish decoder state from transmission events, and route server-framed binary audio to the correct channel.

Receive Audio

  1. Listen for CHANNEL_BUSY. See Requesting the Oracle Radio WebSocket Talk Floor for the channel, talk-floor holder, priority, and expiration properties in this event.

  2. When TRANSMISSION_START arrives, discard any stale decoder state for its channel and create state for the new transmission. The message contract requires type, channel, and user; the format, sampleRate, channels, bitrate, and frameSize decoder properties are optional. See Starting an Oracle Radio WebSocket Audio Transmission.

    Before processing binary audio, verify that the event provides enough settings to configure the decoder. If required decoder information is absent, do not infer defaults or decode the channel's packets.

  3. For each following binary WebSocket message, read the first 2 bytes as the unsigned, big-endian length of the UTF-8 channel name. Read that many channel-name bytes. Treat all remaining bytes as the original encoded audio packet. See Sending Oracle Radio WebSocket Audio for the server-to-client framed audio layout.

  4. Route the packet to the decoder state for the parsed channel. Keep decoder state separate for each channel, and use only the verified decoder settings for the current transmission.

  5. When TRANSMISSION_END arrives, finish playback and discard the matching channel's decoder state. Use the event's transcript only when it is present. See Ending an Oracle Radio WebSocket Audio Transmission.

  6. Process a later TRANSCRIPT_FINAL event when the service provides one. Do not wait indefinitely or assume that every transmission produces this optional event.

  7. Process CHANNEL_OPEN as the notification that the channel is idle. Stop playback and discard the matching channel's decoder state, even if no TRANSMISSION_END event arrived. See Releasing the Oracle Radio WebSocket Talk Floor.

Handle Invalid State and Disconnects

  • Discard a binary message if it is shorter than the 2-byte length field, its channel-name length extends past the message, or it has no matching transmission state. Do not interpret it as unframed client-to-server audio.
  • On a WebSocket disconnect, stop playback and discard all decoder state. Reconnect and subscribe to the required channels again before accepting more channel audio.