mirror of
https://github.com/badaix/snapcast.git
synced 2025-04-28 09:47:09 +02:00
Update binary_protocol.md
This commit is contained in:
parent
fb8f6b87b8
commit
c2bebb4bae
1 changed files with 28 additions and 10 deletions
|
@ -1,6 +1,7 @@
|
||||||
# Snapcast binary protocol
|
# Snapcast binary protocol
|
||||||
|
|
||||||
Each message sent with the Snapcast binary protocol is split up into two parts:
|
Each message sent with the Snapcast binary protocol is split up into two parts:
|
||||||
|
|
||||||
- A base message that provides general information like time sent/received, type of the message, message size, etc
|
- A base message that provides general information like time sent/received, type of the message, message size, etc
|
||||||
- A typed message that carries the rest of the information
|
- A typed message that carries the rest of the information
|
||||||
|
|
||||||
|
@ -24,15 +25,15 @@ When a client joins a server, the following exchanges happen
|
||||||
|
|
||||||
## Messages
|
## Messages
|
||||||
|
|
||||||
| Typed Message ID | Name | Notes |
|
| Typed Message ID | Name | Dir | Notes |
|
||||||
|------------------|--------------------------------------|---------------------------------------------------------------------------|
|
|------------------|--------------------------------------|------|---------------------------------------------------------------------------|
|
||||||
| 0 | [Base](#base) | The beginning of every message containing data about the typed message |
|
| 0 | [Base](#base) | | The beginning of every message containing data about the typed message |
|
||||||
| 1 | [Codec Header](#codec-header) | The codec-specific data to put at the start of a stream to allow decoding |
|
| 1 | [Codec Header](#codec-header) | S->C | The codec-specific data to put at the start of a stream to allow decoding |
|
||||||
| 2 | [Wire Chunk](#wire-chunk) | A part of an audio stream |
|
| 2 | [Wire Chunk](#wire-chunk) | S->C | A part of an audio stream |
|
||||||
| 3 | [Server Settings](#server-settings) | Settings set from the server like volume, latency, etc |
|
| 3 | [Server Settings](#server-settings) | S->C | Settings set from the server like volume, latency, etc |
|
||||||
| 4 | [Time](#time) | Used for synchronizing time with the server |
|
| 4 | [Time](#time) | C->S<br>S->C | Used for synchronizing time with the server |
|
||||||
| 5 | [Hello](#hello) | Sent by the client when connecting with the server |
|
| 5 | [Hello](#hello) | C->S | Sent by the client when connecting with the server |
|
||||||
| 6 | [Stream Tags](#stream-tags) | Metadata about the stream for use by the client |
|
| 7 | [Client Info](#client-info) | C->S | Update the server when relevant information changes (e.g. client volume) |
|
||||||
|
|
||||||
### Base
|
### Base
|
||||||
|
|
||||||
|
@ -63,7 +64,6 @@ The payload depends on the used codec:
|
||||||
- PCM: a RIFF WAVE header, as described [here](https://de.wikipedia.org/wiki/RIFF_WAVE). PCM is not encoded, but the decoder must know the samplerate, bit depth and number of channels, which is encoded into the header
|
- PCM: a RIFF WAVE header, as described [here](https://de.wikipedia.org/wiki/RIFF_WAVE). PCM is not encoded, but the decoder must know the samplerate, bit depth and number of channels, which is encoded into the header
|
||||||
- Opus: a dummy header is sent, containing a 4 byte ID (0x4F505553, ascii for "OPUS"), 4 byte samplerate, 2 byte bit depth, 2 byte channel count (all little endian)
|
- Opus: a dummy header is sent, containing a 4 byte ID (0x4F505553, ascii for "OPUS"), 4 byte samplerate, 2 byte bit depth, 2 byte channel count (all little endian)
|
||||||
|
|
||||||
|
|
||||||
### Wire Chunk
|
### Wire Chunk
|
||||||
|
|
||||||
| Field | Type | Description |
|
| Field | Type | Description |
|
||||||
|
@ -122,3 +122,21 @@ Sample JSON payload (whitespace added for readability):
|
||||||
"Version": "0.17.1"
|
"Version": "0.17.1"
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
### Client Info
|
||||||
|
|
||||||
|
| Field | Type | Description |
|
||||||
|
|---------|--------|----------------------------------------------------------|
|
||||||
|
| size | uint32 | Size of the following JSON string |
|
||||||
|
| payload | char[] | JSON string containing the message (not null terminated) |
|
||||||
|
|
||||||
|
Sample JSON payload (whitespace added for readability):
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"volume": 100,
|
||||||
|
"muted": false,
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
- `volume` can have a value between 0-100 inclusive
|
||||||
|
|
Loading…
Add table
Reference in a new issue