Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion examples/tui_client/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,14 @@ brew install portaudio
./build/examples/tui_client/tui_client "My Player" # custom name
./build/examples/tui_client/tui_client -u ws://192.168.1.10:8928/sendspin # connect to a specific server
./build/examples/tui_client/tui_client -p 8930 # listen on a custom port
./build/examples/tui_client/tui_client -a # allow unpaired access
./build/examples/tui_client/tui_client -V # disable visualizer
```

Press `q` to quit.

## Pairing

The example does not enable unpaired access, so a server has to pair with the client before it can stream. The Server panel shows the connection's trust and, when a server pairs with a code, the six-digit code to enter there. A Pairing Token panel holds the Pairing PSK token to paste into a server that pairs via `pairing_psk`, and disappears once the connection is paired.
By default the example does not enable unpaired access, so a server has to pair with the client before it can stream; with `-a`, a server can stream without pairing once its operator approves the client. The Server panel shows the connection's trust and, when a server pairs with a code, the six-digit code to enter there. A Pairing Token panel holds the Pairing PSK token to paste into a server that pairs via `pairing_psk`, and disappears once the connection is paired.

Identity and pairing records are stored in `~/.sendspin_tui.json`, separate from basic_client's file; delete it to re-provision the client from scratch.
12 changes: 11 additions & 1 deletion examples/tui_client/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,11 @@
/// name: Optional friendly name (default: "TUI Client")
///
/// Options:
/// -u URL Connect to a WebSocket URL (e.g. ws://192.168.1.10:8928/sendspin)
/// -p PORT Listen on PORT (default: 8928)
/// -f FORMAT Audio format as codec:rate:bits:channels (repeatable)
/// -a Enable unpaired access, so a server can stream without pairing first
/// -V Disable visualizer
/// -h Show usage

#include "tui.h"
Expand Down Expand Up @@ -437,18 +440,21 @@ static void print_usage(const char* prog) {
fprintf(stderr, " Can be specified multiple times. Codecs: %s\n",
SUPPORTED_CODECS);
fprintf(stderr, " At least one flac or pcm format is required\n");
fprintf(stderr, " -a Enable unpaired access, so a server can stream without\n");
fprintf(stderr, " pairing first\n");
fprintf(stderr, " -V Disable visualizer\n");
fprintf(stderr, " -h Show this help\n");
}

int main(int argc, char* argv[]) {
// Parse command line options
bool enable_visualizer = true;
bool unpaired_access = false;
std::string connect_url;
uint16_t server_port = DEFAULT_SENDSPIN_PORT;
std::vector<sendspin::AudioSupportedFormatObject> audio_formats;
int opt;
while ((opt = getopt(argc, argv, "u:p:f:Vh")) != -1) {
while ((opt = getopt(argc, argv, "u:p:f:aVh")) != -1) {
switch (opt) {
case 'u':
connect_url = optarg;
Expand All @@ -468,6 +474,9 @@ int main(int argc, char* argv[]) {
audio_formats.push_back(fmt);
break;
}
case 'a':
unpaired_access = true;
break;
case 'V':
enable_visualizer = false;
break;
Expand Down Expand Up @@ -576,6 +585,7 @@ int main(int argc, char* argv[]) {

SendspinClient client(std::move(config));
client.set_persistence_provider(&persistence_provider);
client.set_unpaired_access_enabled(unpaired_access);

// Add roles
#ifdef SENDSPIN_ENABLE_PLAYER
Expand Down
Loading