diff --git a/server/etc/snapserver.conf b/server/etc/snapserver.conf index 4a09ae50..02e3cf1f 100644 --- a/server/etc/snapserver.conf +++ b/server/etc/snapserver.conf @@ -102,7 +102,7 @@ doc_root = /usr/share/snapserver/snapweb # which port the server should listen to #port = 1704 -# stream URI of the PCM input stream, can be configured multiple times +# source URI of the PCM input stream, can be configured multiple times # The following notation is used in this paragraph: # : the whole expression must be replaced with your specific setting # [square brackets]: the whole expression is optional and can be left out @@ -110,9 +110,9 @@ doc_root = /usr/share/snapserver/snapweb # # Format: TYPE://host/path?name=[&codec=][&sampleformat=][&chunk_ms=] # parameters have the form "key=value", they are concatenated with an "&" character -# parameter "name" is mandatory for all streams, while codec, sampleformat and chunk_ms are optional +# parameter "name" is mandatory for all sources, while codec, sampleformat and chunk_ms are optional # and will override the default codec, sampleformat or chunk_ms settings -# Non blocking streams support the dryout_ms parameter: when no new data is read from the stream, send silence to the clients +# Non blocking sources support the dryout_ms parameter: when no new data is read from the source, send silence to the clients # Available types are: # pipe: pipe:///?name=[&mode=create][&dryout_ms=2000], mode can be "create" or "read" # librespot: librespot:///?name=[&dryout_ms=2000][&username=&password=][&devicename=Snapcast][&bitrate=320][&wd_timeout=7800][&volume=100][&onevent=""][&nomalize=false][&autoplay=false] @@ -125,8 +125,9 @@ doc_root = /usr/share/snapserver/snapweb # sampleformat will be set to "44100:16:2" # tcp server: tcp://:?name=[&mode=server] # tcp client: tcp://:?name=&mode=client -stream = pipe:///tmp/snapfifo?name=default -#stream = tcp://127.0.0.1?name=mopidy_tcp +# alsa: alsa://?name=&device= +source = pipe:///tmp/snapfifo?name=default +#source = tcp://127.0.0.1?name=mopidy_tcp # Default sample format #sampleformat = 48000:16:2 @@ -136,7 +137,7 @@ stream = pipe:///tmp/snapfifo?name=default # Type codec:? to get codec specific options #codec = flac -# Default stream read chunk size [ms] +# Default source stream read chunk size [ms] #chunk_ms = 20 # Buffer [ms] diff --git a/server/server.cpp b/server/server.cpp index ca09a9e7..3e40ccf8 100644 --- a/server/server.cpp +++ b/server/server.cpp @@ -692,9 +692,9 @@ void Server::start() streamManager_ = std::make_unique(this, io_context_, settings_.stream.sampleFormat, settings_.stream.codec, settings_.stream.streamChunkMs); // throw SnapException("xxx"); - for (const auto& streamUri : settings_.stream.pcmStreams) + for (const auto& sourceUri : settings_.stream.sources) { - PcmStreamPtr stream = streamManager_->addStream(streamUri); + PcmStreamPtr stream = streamManager_->addStream(sourceUri); if (stream) LOG(INFO, LOG_TAG) << "Stream: " << stream->getUri().toJson() << "\n"; } diff --git a/server/server_settings.hpp b/server/server_settings.hpp index a6ec4f4d..0ebb01b9 100644 --- a/server/server_settings.hpp +++ b/server/server_settings.hpp @@ -51,7 +51,7 @@ struct ServerSettings struct Stream { size_t port{1704}; - std::vector pcmStreams; + std::vector sources; std::string codec{"flac"}; int32_t bufferMs{1000}; std::string sampleFormat{"48000:16:2"}; diff --git a/server/snapserver.cpp b/server/snapserver.cpp index 09c1bff3..a5ce15ea 100644 --- a/server/snapserver.cpp +++ b/server/snapserver.cpp @@ -53,7 +53,7 @@ int main(int argc, char* argv[]) try { ServerSettings settings; - std::string pcmStream = "pipe:///tmp/snapfifo?name=default"; + std::string pcmSource = "pipe:///tmp/snapfifo?name=default"; std::string config_file = "/etc/snapserver.conf"; OptionParser op("Allowed options"); @@ -92,9 +92,11 @@ int main(int argc, char* argv[]) auto stream_bind_to_address = conf.add>("", "stream.bind_to_address", "address for the server to listen on", settings.stream.bind_to_address.front(), &settings.stream.bind_to_address[0]); conf.add>("", "stream.port", "which port the server should listen on", settings.stream.port, &settings.stream.port); - auto streamValue = conf.add>( - "", "stream.stream", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmStream, - &pcmStream); + // deprecated: stream.stream, use stream.source instead + auto streamValue = conf.add>("", "stream.stream", "Deprecated: use stream.source", pcmSource, &pcmSource); + auto sourceValue = conf.add>( + "", "stream.source", "URI of the PCM input stream.\nFormat: TYPE://host/path?name=NAME\n[&codec=CODEC]\n[&sampleformat=SAMPLEFORMAT]", pcmSource, + &pcmSource); conf.add>("", "stream.sampleformat", "Default sample format", settings.stream.sampleFormat, &settings.stream.sampleFormat); conf.add>("", "stream.codec", "Default transport codec\n(flac|ogg|opus|pcm)[:options]\nType codec:? to get codec specific options", @@ -221,13 +223,18 @@ int main(int argc, char* argv[]) else throw SnapException("Invalid log sink: " + settings.logging.sink); - if (!streamValue->is_set()) - settings.stream.pcmStreams.push_back(streamValue->value()); + if (!streamValue->is_set() && !sourceValue->is_set()) + settings.stream.sources.push_back(sourceValue->value()); for (size_t n = 0; n < streamValue->count(); ++n) { LOG(INFO) << "Adding stream: " << streamValue->value(n) << "\n"; - settings.stream.pcmStreams.push_back(streamValue->value(n)); + settings.stream.sources.push_back(streamValue->value(n)); + } + for (size_t n = 0; n < sourceValue->count(); ++n) + { + LOG(INFO) << "Adding source: " << sourceValue->value(n) << "\n"; + settings.stream.sources.push_back(sourceValue->value(n)); } #ifdef HAS_DAEMON