Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2015 Moritz Grimm <mgrimm@mrsserver.net>
|
|
|
|
*
|
|
|
|
* Permission to use, copy, modify, and distribute this software for any
|
|
|
|
* purpose with or without fee is hereby granted, provided that the above
|
|
|
|
* copyright notice and this permission notice appear in all copies.
|
|
|
|
*
|
|
|
|
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
|
|
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
|
|
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
|
|
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
|
|
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
|
|
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
|
|
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
# include "config.h"
|
|
|
|
#endif /* HAVE_CONFIG_H */
|
|
|
|
|
|
|
|
#include "cfg.h"
|
|
|
|
#include "cfg_xmlfile.h"
|
|
|
|
#include "log.h"
|
|
|
|
#include "xalloc.h"
|
|
|
|
|
|
|
|
#include <libxml/parser.h>
|
|
|
|
|
|
|
|
static int _cfg_xmlfile_parse_server(xmlDocPtr, xmlNodePtr);
|
2017-11-17 19:54:14 -05:00
|
|
|
static int _cfg_xmlfile_parse_servers(xmlDocPtr, xmlNodePtr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
static int _cfg_xmlfile_parse_stream(xmlDocPtr, xmlNodePtr);
|
2017-11-17 19:54:14 -05:00
|
|
|
static int _cfg_xmlfile_parse_streams(xmlDocPtr, xmlNodePtr);
|
2017-11-23 12:34:57 -05:00
|
|
|
static int _cfg_xmlfile_parse_intake(xmlDocPtr, xmlNodePtr);
|
|
|
|
static int _cfg_xmlfile_parse_intakes(xmlDocPtr, xmlNodePtr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
static int _cfg_xmlfile_parse_metadata(xmlDocPtr, xmlNodePtr);
|
|
|
|
static int _cfg_xmlfile_parse_decoder(xmlDocPtr, xmlNodePtr);
|
|
|
|
static int _cfg_xmlfile_parse_decoders(xmlDocPtr, xmlNodePtr);
|
|
|
|
static int _cfg_xmlfile_parse_encoder(xmlDocPtr, xmlNodePtr);
|
|
|
|
static int _cfg_xmlfile_parse_encoders(xmlDocPtr, xmlNodePtr);
|
|
|
|
|
2017-09-20 05:32:34 -04:00
|
|
|
#define XML_CHAR(s) (const xmlChar *)(s)
|
|
|
|
#define STD_CHAR(s) (const char *)(s)
|
2016-04-22 09:31:20 -04:00
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
#define XML_SERVER_SET(c, l, f, e) do { \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
2017-11-17 19:54:14 -05:00
|
|
|
int error = 0; \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > (f)((c), (l), STD_CHAR(val), &err_str)) { \
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: server (%s): %s: %s", \
|
|
|
|
doc->name, xmlGetLineNo(cur), \
|
|
|
|
cfg_server_get_name((c)), (e), err_str); \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
2017-11-17 19:54:14 -05:00
|
|
|
if (error) \
|
|
|
|
return (-1); \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_server(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
2017-11-17 19:54:14 -05:00
|
|
|
cfg_server_list_t sl;
|
|
|
|
cfg_server_t s;
|
|
|
|
const char *errstr;
|
|
|
|
long int line_no = xmlGetLineNo(cur);
|
|
|
|
|
|
|
|
sl = cfg_get_servers();
|
|
|
|
s = cfg_server_list_get(sl, CFG_DEFAULT);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-17 19:54:14 -05:00
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_name, "name");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_protocol, "protocol");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_hostname, "hostname");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_port, "port");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_user, "user");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_password, "password");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_reconnect_attempts, "reconnect_attempts");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_tls, "tls");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_tls_cipher_suite, "tls_cipher_suite");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_ca_dir, "ca_dir");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_ca_file, "ca_file");
|
|
|
|
XML_SERVER_SET(s, sl, cfg_server_set_client_cert, "client_cert");
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
if (0 > cfg_server_validate(s, &errstr)) {
|
|
|
|
log_error("%s[%ld]: server (%s): %s", doc->name, line_no,
|
|
|
|
cfg_server_get_name(s), errstr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
return (-1);
|
2017-11-17 19:54:14 -05:00
|
|
|
}
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_servers(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("server")) &&
|
|
|
|
0 > _cfg_xmlfile_parse_server(doc, cur))
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define XML_STREAM_SET(c, l, f, e) do { \
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
|
|
|
int error = 0; \
|
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > (f)((c), (l), STD_CHAR(val), &err_str)) { \
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: stream (%s): %s: %s", \
|
|
|
|
doc->name, xmlGetLineNo(cur), \
|
|
|
|
cfg_stream_get_name((c)), (e), err_str); \
|
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
|
|
|
if (error) \
|
|
|
|
return (-1); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_stream(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
2017-11-17 19:54:14 -05:00
|
|
|
cfg_stream_list_t sl;
|
|
|
|
cfg_stream_t s;
|
|
|
|
const char *errstr;
|
|
|
|
long int line_no = xmlGetLineNo(cur);
|
|
|
|
|
|
|
|
sl = cfg_get_streams();
|
|
|
|
s = cfg_stream_list_get(sl, CFG_DEFAULT);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-17 19:54:14 -05:00
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_name, "name");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_mountpoint, "mountpoint");
|
2017-11-23 12:34:57 -05:00
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_intake, "intake");
|
2017-11-17 19:54:14 -05:00
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_server, "server");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_public, "public");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_format, "format");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_encoder, "encoder");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_url, "stream_url");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_genre, "stream_genre");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_description, "stream_description");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_quality, "stream_quality");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_bitrate, "stream_bitrate");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_samplerate, "stream_samplerate");
|
|
|
|
XML_STREAM_SET(s, sl, cfg_stream_set_stream_channels, "stream_channels");
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
if (0 > cfg_stream_validate(s, &errstr)) {
|
|
|
|
log_error("%s[%ld]: stream (%s): %s", doc->name, line_no,
|
|
|
|
cfg_stream_get_name(s), errstr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
return (-1);
|
2017-11-17 19:54:14 -05:00
|
|
|
}
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_streams(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("stream")) &&
|
|
|
|
0 > _cfg_xmlfile_parse_stream(doc, cur))
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-23 12:34:57 -05:00
|
|
|
#define XML_INPUT_SET(c, l, f, e) do { \
|
2017-11-17 19:54:14 -05:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
2017-11-23 12:34:57 -05:00
|
|
|
int error = 0; \
|
2017-11-17 19:54:14 -05:00
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > (f)((c), (l), STD_CHAR(val), &err_str)) { \
|
|
|
|
log_error("%s[%ld]: intake (%s): %s: %s", \
|
|
|
|
doc->name, xmlGetLineNo(cur), \
|
|
|
|
cfg_intake_get_name((c)), (e), err_str); \
|
2017-11-17 19:54:14 -05:00
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (error) \
|
|
|
|
return (-1); \
|
2017-11-17 19:54:14 -05:00
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
static int
|
2017-11-23 12:34:57 -05:00
|
|
|
_cfg_xmlfile_parse_intake(xmlDocPtr doc, xmlNodePtr cur)
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
{
|
2017-11-23 12:34:57 -05:00
|
|
|
cfg_intake_list_t il;
|
|
|
|
cfg_intake_t i;
|
|
|
|
const char *errstr;
|
|
|
|
long int line_no = xmlGetLineNo(cur);
|
|
|
|
|
|
|
|
il = cfg_get_intakes();
|
|
|
|
i = cfg_intake_list_get(il, CFG_DEFAULT);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-23 12:34:57 -05:00
|
|
|
XML_INPUT_SET(i, il, cfg_intake_set_name, "name");
|
|
|
|
XML_INPUT_SET(i, il, cfg_intake_set_type, "type");
|
|
|
|
XML_INPUT_SET(i, il, cfg_intake_set_filename, "filename");
|
|
|
|
XML_INPUT_SET(i, il, cfg_intake_set_shuffle, "shuffle");
|
|
|
|
XML_INPUT_SET(i, il, cfg_intake_set_stream_once, "stream_once");
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
}
|
|
|
|
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > cfg_intake_validate(i, &errstr)) {
|
|
|
|
log_error("%s[%ld]: intake (%s): %s", doc->name, line_no,
|
|
|
|
cfg_intake_get_name(i), errstr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
return (-1);
|
2017-11-23 12:34:57 -05:00
|
|
|
}
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-23 12:34:57 -05:00
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_intakes(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("intake")) &&
|
|
|
|
0 > _cfg_xmlfile_parse_intake(doc, cur))
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
#define XML_STRCONFIG(s, f, e) do { \
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
|
|
|
if (0 > (f)(STD_CHAR(val), &err_str)) { \
|
|
|
|
log_error("%s[%ld]: %s: %s: %s", doc->name, \
|
|
|
|
xmlGetLineNo(cur), (s), (e), err_str); \
|
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_metadata(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
XML_STRCONFIG("metadata", cfg_set_metadata_program, "program");
|
|
|
|
XML_STRCONFIG("metadata", cfg_set_metadata_format_str, "format_str");
|
|
|
|
XML_STRCONFIG("metadata", cfg_set_metadata_refresh_interval,
|
|
|
|
"refresh_interval");
|
|
|
|
XML_STRCONFIG("metadata", cfg_set_metadata_normalize_strings,
|
|
|
|
"normalize_strings");
|
|
|
|
XML_STRCONFIG("metadata", cfg_set_metadata_no_updates, "no_updates");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (error)
|
|
|
|
return (-1);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
#define XML_DECODER_SET(c, l, f, e) do { \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
|
|
|
int error = 0; \
|
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > (f)((c), (l), STD_CHAR(val), &err_str)) { \
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: decoder (%s): %s: %s", \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
doc->name, xmlGetLineNo(cur), \
|
|
|
|
cfg_decoder_get_name((c)), (e), err_str); \
|
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
|
|
|
if (error) \
|
|
|
|
return (-1); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_decoder(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
2017-11-17 19:54:14 -05:00
|
|
|
cfg_decoder_list_t dl;
|
|
|
|
cfg_decoder_t d;
|
|
|
|
const char *errstr;
|
|
|
|
long int line_no = xmlGetLineNo(cur);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
dl = cfg_get_decoders();
|
|
|
|
d = cfg_decoder_list_get(dl, CFG_DEFAULT);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-17 19:54:14 -05:00
|
|
|
XML_DECODER_SET(d, dl, cfg_decoder_set_name, "name");
|
|
|
|
XML_DECODER_SET(d, dl, cfg_decoder_set_program, "program");
|
|
|
|
XML_DECODER_SET(d, dl, cfg_decoder_add_match, "file_ext");
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > cfg_decoder_validate(d, &errstr)) {
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: decoder (%s): %s", doc->name, line_no,
|
|
|
|
cfg_decoder_get_name(d), errstr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_decoders(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("decoder")) &&
|
|
|
|
0 > _cfg_xmlfile_parse_decoder(doc, cur))
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
#define XML_ENCODER_SET(c, l, f, e) do { \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR((e)))) { \
|
|
|
|
xmlChar *val; \
|
|
|
|
const char *err_str; \
|
|
|
|
int error = 0; \
|
|
|
|
\
|
|
|
|
val = xmlNodeListGetString(doc, cur->xmlChildrenNode, 1); \
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 > (f)((c), (l), STD_CHAR(val), &err_str)) { \
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: encoder (%s): %s: %s", \
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
doc->name, xmlGetLineNo(cur), \
|
|
|
|
cfg_encoder_get_name((c)), (e), err_str); \
|
|
|
|
error = 1; \
|
|
|
|
} \
|
|
|
|
xmlFree(val); \
|
|
|
|
if (error) \
|
|
|
|
return (-1); \
|
|
|
|
} \
|
|
|
|
} while (0)
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_encoder(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
2017-11-17 19:54:14 -05:00
|
|
|
cfg_encoder_list_t el;
|
|
|
|
cfg_encoder_t e;
|
|
|
|
const char *errstr;
|
|
|
|
long int line_no = xmlGetLineNo(cur);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
2017-11-17 19:54:14 -05:00
|
|
|
el = cfg_get_encoders();
|
|
|
|
e = cfg_encoder_list_get(el, CFG_DEFAULT);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-17 19:54:14 -05:00
|
|
|
XML_ENCODER_SET(e, el, cfg_encoder_set_name, "name");
|
|
|
|
XML_ENCODER_SET(e, el, cfg_encoder_set_format_str, "format");
|
|
|
|
XML_ENCODER_SET(e, el, cfg_encoder_set_program, "program");
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
if (0 > cfg_encoder_validate(e, &errstr)) {
|
2017-11-17 19:54:14 -05:00
|
|
|
log_error("%s[%ld]: encoder (%s): %s", doc->name, line_no,
|
|
|
|
cfg_encoder_get_name(e), errstr);
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
_cfg_xmlfile_parse_encoders(xmlDocPtr doc, xmlNodePtr cur)
|
|
|
|
{
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("encoder")) &&
|
|
|
|
0 > _cfg_xmlfile_parse_encoder(doc, cur))
|
|
|
|
return (-1);
|
|
|
|
}
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* XML configuration file structure:
|
|
|
|
*
|
|
|
|
* ezstream
|
2017-11-17 19:54:14 -05:00
|
|
|
* servers
|
|
|
|
* server
|
|
|
|
* name
|
|
|
|
* protocol
|
|
|
|
* hostname
|
|
|
|
* port
|
|
|
|
* user
|
|
|
|
* password
|
|
|
|
* reconnect_attempts
|
|
|
|
* tls
|
|
|
|
* tls_cipher_suite
|
|
|
|
* ca_dir
|
|
|
|
* ca_file
|
|
|
|
* client_cert
|
|
|
|
* ...
|
|
|
|
* streams
|
|
|
|
* stream
|
|
|
|
* name
|
|
|
|
* mountpoint
|
|
|
|
* public
|
2017-11-23 12:34:57 -05:00
|
|
|
* intake
|
2017-11-17 19:54:14 -05:00
|
|
|
* server
|
|
|
|
* format
|
|
|
|
* encoder
|
|
|
|
* stream_name
|
|
|
|
* stream_url
|
|
|
|
* stream_genre
|
|
|
|
* stream_description
|
|
|
|
* stream_quality
|
|
|
|
* stream_bitrate
|
|
|
|
* stream_samplerate
|
|
|
|
* stream_channels
|
|
|
|
* ...
|
2017-11-23 12:34:57 -05:00
|
|
|
* intakes
|
|
|
|
* intake
|
|
|
|
* type
|
|
|
|
* filename
|
|
|
|
* shuffle
|
|
|
|
* stream_once
|
|
|
|
* ...
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
* metadata
|
|
|
|
* program
|
|
|
|
* format_str
|
|
|
|
* refresh_interval
|
|
|
|
* normalize_strings
|
|
|
|
* no_updates
|
|
|
|
* decoders
|
|
|
|
* decoder
|
|
|
|
* name
|
|
|
|
* program
|
|
|
|
* file_ext
|
|
|
|
* ...
|
|
|
|
* ...
|
|
|
|
* encoders
|
|
|
|
* encoder
|
|
|
|
* name
|
|
|
|
* format
|
|
|
|
* program
|
|
|
|
* ...
|
|
|
|
*/
|
|
|
|
int
|
|
|
|
cfg_xmlfile_parse(const char *config_file)
|
|
|
|
{
|
|
|
|
xmlDocPtr doc = NULL;
|
|
|
|
xmlNodePtr cur = NULL;
|
|
|
|
int error = 0;
|
|
|
|
|
|
|
|
xmlLineNumbersDefault(1);
|
|
|
|
|
2015-05-06 13:00:23 -04:00
|
|
|
if (0 > cfg_file_check(config_file))
|
|
|
|
goto error;
|
|
|
|
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
doc = xmlParseFile(config_file);
|
|
|
|
if (!doc) {
|
|
|
|
log_error("%s: not well-formed XML", config_file);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (!doc->name)
|
2016-04-22 09:31:20 -04:00
|
|
|
doc->name = (char *)xmlStrdup(XML_CHAR(config_file));
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
cur = xmlDocGetRootElement(doc);
|
|
|
|
if (!cur) {
|
|
|
|
log_error("%s: empty document", config_file);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
if (0 != xmlStrcasecmp(cur->name, XML_CHAR("ezstream"))) {
|
|
|
|
log_error("%s: not ezstream config", config_file);
|
|
|
|
goto error;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (cur = cur->xmlChildrenNode; cur; cur = cur->next) {
|
2017-11-17 19:54:14 -05:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("servers"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_servers(doc, cur))
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2017-11-17 19:54:14 -05:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("streams"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_streams(doc, cur))
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
2017-11-23 12:34:57 -05:00
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("intakes"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_intakes(doc, cur))
|
Refactor configuration (work in progress)
* Move -m and -n command line options into the config file
* Restructure configuration file:
- Group into "server", "stream", "media", "metadata", "decoders", and
"encoders"
- Untangle decoder and encoder:
o Decoders match on file extensions and convert to a canonical "internal"
format
o Encoders create one of the supported stream formats, potentially using
different parameters (like bitrate)
- Consistently specify stream format
- Enable reencoding by selecting an encoder
* Architecturally separate configuration file storage from parsing
- Allows for different configuration back-ends in the future, like
YAML, SQL, REST API, ...
* Support roll-back in case of error on (re)load
* Anticipate HTTPS support
2015-05-02 06:48:53 -04:00
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("metadata"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_metadata(doc, cur))
|
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("decoders"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_decoders(doc, cur))
|
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
if (0 == xmlStrcasecmp(cur->name, XML_CHAR("encoders"))) {
|
|
|
|
if (0 > _cfg_xmlfile_parse_encoders(doc, cur))
|
|
|
|
error = 1;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if (error)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
|
|
|
|
return (0);
|
|
|
|
|
|
|
|
error:
|
|
|
|
if (doc)
|
|
|
|
xmlFreeDoc(doc);
|
|
|
|
|
|
|
|
return (-1);
|
|
|
|
}
|