Sending Oracle Radio WebSocket Audio

Send each audio packet as an unframed binary WebSocket message during an active Radio audio transmission.

Permissions and Prerequisites

The following permissions and prerequisites apply to this operation.

RequirementValue
AuthenticationComplete the supported authentication path for the client before sending this operation. See authentication.
Radio permissionradio.audio.transmit
Channel accessThe authenticated user must have talk access to the active channel.
Session stateThe WebSocket connection must be open, the talk token must be valid for the active channel, and the client must have sent START. Use only the token granted to the authenticated user, and don't transfer it to another user or client.

Request

This binary input has no JSON parameters and no per-message Content-Type field. Send one complete binary WebSocket message that contains only the encoded audio packet.

For a JavaScript WebSocket client, call this function after successfully sending START. The encodedAudioPacket argument contains one packet encoded by using the audio settings declared in START.

function sendAudioPacket(webSocket, encodedAudioPacket) {
  if (webSocket.readyState !== WebSocket.OPEN) {
    throw new Error("WebSocket connection is not open");
  }
  webSocket.send(encodedAudioPacket);
}

Payload

The following table describes the binary audio payload sent by the client.

AttributeValueDescription
WebSocket message typeBinaryUse a binary WebSocket message, not a JSON text message.
API content typeapplication/octet-streamThis is the media type in the API contract. It isn't a field or header in the WebSocket message.
DataEncoded audio bytesSend one audio packet in the format declared by START. Don't add the channel prefix used by server-to-client audio.

Protocol Constraints

Follow these requirements when sending audio packets during an active transmission.

ConstraintRequirement
Transmission stateSend packets after START and before END, while the talk token is valid.
Packet encodingUse the format, sample rate, channel count, bitrate, and frame size declared by START.
Audio-session sizeSend at most 50 MiB of audio for one session.
Metadata packetsThe service recognizes packets starting with OpusHead or OpusTags as metadata and ignores them.

Responses

The following table lists the messages the client can receive and explains their purpose.

Message typeKindDescription
Framed audio packetBinary relayOther subscribed connections receive the original audio packet with a channel-name prefix added by the server.
TOKEN_INVALIDDirect errorIndicates that no current talk token controls the transmission. Stop sending audio.
ERRORDirect errorIndicates that the audio session exceeded 50 MiB or another packet-processing error occurred.
INTERRUPTEDAsynchronous eventIndicates that a higher-priority user took the talk floor. Stop sending audio.
TOKEN_EXPIREDAsynchronous eventIndicates that the talk token expired. Stop sending audio.
TRANSMISSION_TIMEOUTAsynchronous eventIndicates that the transmission timed out and the token was automatically released.
Note

The initiating session doesn't receive a relayed copy of its binary audio. Continue based on local WebSocket send completion; don't wait for an audio echo.

Framed Audio Packet

The following table describes the parts of an audio packet relayed by the server.

PartData typeRequiredDescription
Channel-name length2-byte unsigned integerYesLength of the UTF-8 channel name in big-endian byte order.
Channel nameUTF-8 bytesYesSource channel. Its length is specified by the first two bytes.
Audio packetbinaryYesAll remaining bytes. These are the original client audio packet.
Note

Client-to-server and server-to-client binary messages use different layouts. Don't send the server-added channel prefix back to the service.