Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New setting "streaming_client.initial_volume" #1024

Merged
merged 4 commits into from
Jul 2, 2022
Merged
Show file tree
Hide file tree
Changes from 3 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
1 change: 1 addition & 0 deletions doc/configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ Within the `[stream]` section there are some global parameters valid for all `so
- `chunk_ms`: Default source stream read chunk size [ms]. The server will continously read this number of milliseconds from the source into a buffer, before this buffer is passed to the encoder (the `codec` above)
- `buffer`: Buffer [ms]. The end-to-end latency, from capturing a sample on the server until the sample is played-out on the client
- `send_to_muted`: `true` or `false`: Send audio to clients that are muted
- `initial_client_percent`: 0-100 [percent]: The volume an audio client gets assigned on very first connect (i.e. client not known to snapserver yet). Defaults to 100 if unset or invalid (e.g. out of bounds).
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please change according to the requested changes for server/etc/snapserver.conf (below).


`source` parameters have the form `key=value`, they are concatenated with an `&` character.
Supported parameters for all source types:
Expand Down
5 changes: 5 additions & 0 deletions server/etc/snapserver.conf
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,11 @@ source = pipe:///tmp/snapfifo?name=default
# Send audio to muted clients
#send_to_muted = false
#

# Volume assigned to new snapclients [percent]
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you please create a new config section streaming_client?
Because this is not really related to a stream, but to a client, and there are two kinds of clients: streaming and control.
Maybe this section will be extended later with e.g. black lists, white lists of client IPs or certificates and what not.

Also please rename the setting to initial_volume and keep the comment that the unit is percent, like this:

# streaming client options ####################################################
#
[streaming_client]

# Volume assigned to new snapclients [percent]
# Defaults to 100 if unset
#initial_volume = 100
#
###############################################################################

# Defaults to 100 if unset
#initial_client_percent = 100
#
###############################################################################


Expand Down
4 changes: 4 additions & 0 deletions server/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -767,6 +767,10 @@ void Server::onMessageReceived(StreamSession* streamSession, const msg::BaseMess
}

ClientInfoPtr client = group->getClient(streamSession->clientId);
if (newGroup)
{
client->config.volume.percent = settings_.stream.initialClientPercent;
}

LOG(DEBUG, LOG_TAG) << "Sending ServerSettings to " << streamSession->clientId << "\n";
auto serverSettings = make_shared<msg::ServerSettings>();
Expand Down
1 change: 1 addition & 0 deletions server/server_settings.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ struct ServerSettings
size_t streamChunkMs{20};
bool sendAudioToMutedClients{false};
std::vector<std::string> bind_to_address{{"0.0.0.0"}};
uint16_t initialClientPercent{100};
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add a new struct StreamingClient with uint16_t initialVolume

};

struct Logging
Expand Down
2 changes: 2 additions & 0 deletions server/snapserver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,8 @@ int main(int argc, char* argv[])
conf.add<Value<int>>("", "stream.buffer", "Buffer [ms]", settings.stream.bufferMs, &settings.stream.bufferMs);
conf.add<Value<bool>>("", "stream.send_to_muted", "Send audio to muted clients", settings.stream.sendAudioToMutedClients,
&settings.stream.sendAudioToMutedClients);
conf.add<Value<uint16_t>>("", "stream.initial_client_percent", "Volume assigned to new snapclients", settings.stream.initialClientPercent,
&settings.stream.initialClientPercent);

// logging settings
conf.add<Value<string>>("", "logging.sink", "log sink [null,system,stdout,stderr,file:<filename>]", settings.logging.sink, &settings.logging.sink);
Expand Down