From ed9e84f38718f656b6924b8a72c700a9a9d91299 Mon Sep 17 00:00:00 2001 From: Moritz Grimm Date: Sat, 18 Nov 2017 01:54:14 +0100 Subject: [PATCH] Change config format to (eventually) support concurrent streams to many servers Everything ties together in stream configurations, of which there can be many now. For the time being, every stream configuration but the "default" is ignored. Every stream/server/encoder/decoder configuration now has the name "default" by default, so that configuring names is only needed to resolve ambiguities. Decoder configurations are now also constrained in this manner for consistency, meaning they are no longer uniquely identified by a number of file extensions but also a name. --- doc/ezstream.1.in.in | 177 +++++--- examples/ezstream-file_template.xml | 24 +- examples/ezstream-full.xml | 127 +++--- examples/ezstream-minimal.xml | 20 +- examples/ezstream-stdin.xml | 20 +- examples/ezstream-video.xml | 22 +- src/Makefile.am | 4 + src/cfg.c | 592 +++++--------------------- src/cfg.h | 110 +---- src/cfg_decoder.c | 153 +++++-- src/cfg_decoder.h | 30 +- src/cfg_encoder.c | 129 ++++-- src/cfg_encoder.h | 27 +- src/cfg_private.h | 66 +-- src/cfg_server.c | 409 ++++++++++++++++++ src/cfg_server.h | 105 +++++ src/cfg_stream.c | 410 ++++++++++++++++++ src/cfg_stream.h | 97 +++++ src/cfg_xmlfile.c | 309 +++++++++----- src/ezstream.c | 76 ++-- src/stream.c | 215 ++++++---- src/stream.h | 18 +- tests/Makefile.am | 50 ++- tests/check_cfg.c | 630 +--------------------------- tests/check_cfg.h | 205 +++++++++ tests/check_cfg_decoder.c | 192 +++++++++ tests/check_cfg_encoder.c | 184 ++++++++ tests/check_cfg_server.c | 248 +++++++++++ tests/check_cfg_stream.c | 223 ++++++++++ tests/check_cfg_xmlfile.c | 7 +- tests/check_stream.c | 101 ++--- tests/config-bad.xml | 63 +-- tests/config-bad5.xml | 55 +++ 33 files changed, 3245 insertions(+), 1853 deletions(-) create mode 100644 src/cfg_server.c create mode 100644 src/cfg_server.h create mode 100644 src/cfg_stream.c create mode 100644 src/cfg_stream.h create mode 100644 tests/check_cfg.h create mode 100644 tests/check_cfg_decoder.c create mode 100644 tests/check_cfg_encoder.c create mode 100644 tests/check_cfg_server.c create mode 100644 tests/check_cfg_stream.c create mode 100644 tests/config-bad5.xml diff --git a/doc/ezstream.1.in.in b/doc/ezstream.1.in.in index ac5d662..930488b 100644 --- a/doc/ezstream.1.in.in +++ b/doc/ezstream.1.in.in @@ -93,8 +93,7 @@ Increase logging verbosity. May be used up to three times to also include debug logging output. .El .Ss Runtime control -On POSIX systems, -.Nm +.Nm Ezstream offers limited runtime control via signals. By sending a signal to the ezstream process, e.g. with the .Xr kill 1 @@ -148,20 +147,40 @@ like in the introductory example shown above. .It Sy \& .Pq Mandatory. The configuration file's root element. -It contains all other configuration elements: +It contains all other configuration elements. .Pp .El +.Ss Servers block +.Bl -tag -width -Ds +.It Sy \& +This element contains all server blocks as child elements. +Its parent is the +.Sy \& +element. +.Pp +A configuration file may contain multiple named server configurations. +The stream configuration determines what server configuration should be used. +.El .Ss Server block .Bl -tag -width -Ds .It Sy \& .Pq Mandatory. -This element contains the entire server configuration as child elements. +This element contains a complete server configuration as child elements. Its parent is the -.Sy \& +.Sy \& element. .El .Ss Server configuration .Bl -tag -width -Ds +.It Sy \& +Set the name of the server configuration. +This may be referenced in a +.Sy \& . +.Pp +The name is case-aware, but not case-sensitive. +.Pp +Default: +.Ar default .It Sy \& Transport protocol used to stream to the server: .Pp @@ -187,6 +206,14 @@ Default: .It Sy \& .Pq Mandatory. Password to authenticate with on the server. +.It Sy \& +Number of reconnect attempts in case of connection issues with the server, +or 0 +.Pq zero +for trying indefinitely. +.Pp +Default: +.Ar 0 .It Sy \& Configure the TLS encryption requirement for the server connection. Possible values are: @@ -233,11 +260,21 @@ server. .Pp Default: .Em no client certificate authentication -.It Sy \& -Number of reconnect attempts in case of connection issues with the server, -or 0 -.Pq zero -for trying indefinitely (the default). +.El +.Ss Streams block +.Bl -tag -width -Ds +.It Sy \& +This element contains all stream blocks as child elements. +Its parent is the +.Sy \& +element. +.Pp +.Em Note: +While multiple stream configurations are supported by the file format, only +the one configuration with the name +.Ar default +will be used by +.Nm . .El .Ss Stream block .Bl -tag -width -Ds @@ -245,55 +282,22 @@ for trying indefinitely (the default). .Pq Mandatory. This element contains the entire stream configuration as child elements. Its parent is the -.Sy \& +.Sy \& element. .El .Ss Stream configuration .Bl -tag -width -Ds +.It Sy \& +Set the name of the stream configuration. +.Pp +The name is case-aware, but not case-sensitive. +.Pp +Default: +.Ar default .It Sy \& .Pq Mandatory. Stream mountpoint on the server. -.It Sy \& -Informational name of the broadcast. -.Pp -Default: -.Em none -.It Sy \& -Informational URL associated with the broadcast, e.g. the web site. -.Pp -Default: -.Em none -.It Sy \& -Informational genre of the broadcast. -.Pp -Default: -.Em none -.It Sy \& -Informational description of the broadcast. -.Pp -Default: -.Em none -.It Sy \& -Informational quality setting of the VBR broadcast. -.Pp -Default: -.Em none -.It Sy \& -Informational bitrate setting of the CBR broadcast. -.Pp -Default: -.Em none -.It Sy \& -Informational sample rate of the broadcast audio. -.Pp -Default: -.Em none -.It Sy \& -Informational number of audio channels of the broadcast. -.Pp -Default: -.Em none -.It Sy \& +.It Sy \& Boolean setting of whether the broadcast may be listed in a public YP directory, or not. .Pp @@ -303,6 +307,11 @@ The broadcast is private (the default). .It Ar 1|Yes|True The broadcast is public. .El +.It Sy \& +Use the server configuration with the provided symbolic name for this stream. +.Pp +Default: +.Ar default .It Sy \& .Pq Mandatory. The stream format. @@ -316,9 +325,9 @@ MP3 audio format Ogg Theora video format .El .It Sy \& -Set the encoder by its configured symbolic name +Use the encoder configuration with the provided symbolic name .Pq see below , -which should be used to (re)encode the stream. +for (re)encoding the stream. Not configuring an encoder makes .Nm stream input media files as-is. @@ -326,6 +335,46 @@ stream input media files as-is. The configured encoder's output stream format must match what is configured in .Sy \& . +.It Sy \& +Informational name of the broadcast. +.Pp +Default: +.Em none +.It Sy \& +Informational URL associated with the broadcast, e.g. the web site. +.Pp +Default: +.Em none +.It Sy \& +Informational genre of the broadcast. +.Pp +Default: +.Em none +.It Sy \& +Informational description of the broadcast. +.Pp +Default: +.Em none +.It Sy \& +Informational quality setting of the VBR broadcast. +.Pp +Default: +.Em none +.It Sy \& +Informational bitrate setting of the CBR broadcast. +.Pp +Default: +.Em none +.It Sy \& +Informational sample rate of the broadcast audio. +.Pp +Default: +.Em none +.It Sy \& +Informational number of audio channels of the broadcast. +.Pp +Default: +.Em none .El .Ss Media block .Bl -tag -width -Ds @@ -477,18 +526,16 @@ This element contains all configuration of a single decoder. Its parent is the .Sy \& element. -.Pp -Many decoders can be configured, but a filename extension can only be -associated with one decoder. .El .Ss Decoder configuration .Bl -tag -width -Ds .It Sy \& Set the name of the decoder configuration. -Choosing a meaningful, unique name is beneficial for logging and debugging. +.Pp +The name is case-aware, but not case-sensitive. .Pp Default: -.Em autoincrementing index +.Ar default .It Sy \& .Pq Mandatory. Set the full command line to decode a media input file, represented by the @@ -513,6 +560,8 @@ It is possible to specify more than one .Sy \& element per decoder to associate more than one file extension to the same decoder. +.Pp +A filename extension can only be associated with one decoder. .El .Ss Encoders block .Bl -tag -width -Ds @@ -529,18 +578,20 @@ This element contains all configuration of a single encoder. Its parent is the .Sy \& element. -.Pp -Many encoders can be configured. .El .Ss Encoder configuration .Bl -tag -width -Ds .It Sy \& .Pq Mandatory. -Set the name of the encoder configuration, to be referenced in the +Set the name of the encoder configuration. +This may be referenced in a .Sy \& block in case (re)encoding is desired. .Pp The name is case-aware, but not case-sensitive. +.Pp +Default: +.Ar default .It Sy \& .Pq Mandatory. Stream format produced by this encoder. @@ -549,7 +600,7 @@ This must be one of the available stream formats as specified for the block. .It Sy \& .Pq Mandatory. -Set the full command line to encode +Set the full command line to encode the .Dq canonical internal format from standard input into a supported stream format on standard output. .Pp diff --git a/examples/ezstream-file_template.xml b/examples/ezstream-file_template.xml index fbfe82b..713954d 100644 --- a/examples/ezstream-file_template.xml +++ b/examples/ezstream-file_template.xml @@ -10,17 +10,21 @@ - - 127.0.0.1 - 8000 - hackme - + + + 127.0.0.1 + 8000 + hackme + + - - /stream.ogg - Vorbis - OggEnc-Q1.5 - + + + /stream.ogg + Vorbis + OggEnc-Q1.5 + + %FILENAME% diff --git a/examples/ezstream-full.xml b/examples/ezstream-full.xml index b908e38..dbb9392 100644 --- a/examples/ezstream-full.xml +++ b/examples/ezstream-full.xml @@ -13,78 +13,91 @@ - - - HTTP - - 127.0.0.1 - - 8000 + + + + Default - - source - - hackme + + HTTP + + 127.0.0.1 + + 8000 - - Required + + source + + hackme - - HIGH:!kRSA:!kECDH:!DH:!PKS:!aNULL:!eNULL:!3DES:!MD5:!SHA:!TLSv1 + + 0 - - /etc/ssl/certs + + Required - - /etc/ssl/certs/ca-certificates.crt + + HIGH:!kRSA:!kECDH:!DH:!PKS:!aNULL:!eNULL:!3DES:!MD5:!SHA:!TLSv1 - - /etc/ssl/ezstream.crt + + /etc/ssl/certs - - 0 - + + /etc/ssl/certs/ca-certificates.crt + + + /etc/ssl/ezstream.crt + + - - - /stream.ogg + + + + Default - - Test Stream - http://localhost:8000/ - Beeps - Test tones and noise - 1.5 - 16 - 44100 - 2 + + /stream.ogg - - No + + Default - - Vorbis + + No - - OggEnc-Q1.5 - + + Vorbis + + + OggEnc-Q1.5 + + + Test Stream + http://localhost:8000/ + Beeps + Test tones and noise + 1.5 + 16 + 44100 + 2 + + + - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + diff --git a/tests/config-bad5.xml b/tests/config-bad5.xml new file mode 100644 index 0000000..7f0e23d --- /dev/null +++ b/tests/config-bad5.xml @@ -0,0 +1,55 @@ + + + + + + + localhost + secret + duplicate + + + localhost + secret + duplicate + + + + + + vorbis + duplicate + + + vorbis + duplicate + + + + + + true @T@ + duplicate + .ogg + + + true @T@ + duplicate + .ogg + + + + + + + vorbis + duplicate + + + vorbis + duplicate + + + + +