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.
| Requirement | Value |
|---|---|
| Authentication | Complete the supported authentication path for the client before sending this operation. See authentication. |
| Radio permission | radio.audio.transmit |
| Channel access | The authenticated user must have talk access to the active channel. |
| Session state | The 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.
| Attribute | Value | Description |
|---|---|---|
| WebSocket message type | Binary | Use a binary WebSocket message, not a JSON text message. |
| API content type | application/octet-stream | This is the media type in the API contract. It isn't a field or header in the WebSocket message. |
| Data | Encoded audio bytes | Send 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.
| Constraint | Requirement |
|---|---|
| Transmission state | Send packets after START and before END, while the talk token is valid. |
| Packet encoding | Use the format, sample rate, channel count, bitrate, and frame size declared by START. |
| Audio-session size | Send at most 50 MiB of audio for one session. |
| Metadata packets | The 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 type | Kind | Description |
|---|---|---|
| Framed audio packet | Binary relay | Other subscribed connections receive the original audio packet with a channel-name prefix added by the server. |
TOKEN_INVALID | Direct error | Indicates that no current talk token controls the transmission. Stop sending audio. |
ERROR | Direct error | Indicates that the audio session exceeded 50 MiB or another packet-processing error occurred. |
INTERRUPTED | Asynchronous event | Indicates that a higher-priority user took the talk floor. Stop sending audio. |
TOKEN_EXPIRED | Asynchronous event | Indicates that the talk token expired. Stop sending audio. |
TRANSMISSION_TIMEOUT | Asynchronous event | Indicates that the transmission timed out and the token was automatically released. |
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.
| Part | Data type | Required | Description |
|---|---|---|---|
| Channel-name length | 2-byte unsigned integer | Yes | Length of the UTF-8 channel name in big-endian byte order. |
| Channel name | UTF-8 bytes | Yes | Source channel. Its length is specified by the first two bytes. |
| Audio packet | binary | Yes | All remaining bytes. These are the original client audio packet. |
Client-to-server and server-to-client binary messages use different layouts. Don't send the server-added channel prefix back to the service.